diff options
author | robert <robert@FreeBSD.org> | 2002-10-16 14:00:46 +0000 |
---|---|---|
committer | robert <robert@FreeBSD.org> | 2002-10-16 14:00:46 +0000 |
commit | ea03112dbfc5c3e2bd1036cae5b8a2bbd59bcefc (patch) | |
tree | f842a8fc345135dd3f0a7b4514d049f10569985e /lib/libc/stdlib/insque.c | |
parent | 1e67ecad50f463bed6a712df9a25865e9a8bc358 (diff) | |
download | FreeBSD-src-ea03112dbfc5c3e2bd1036cae5b8a2bbd59bcefc.zip FreeBSD-src-ea03112dbfc5c3e2bd1036cae5b8a2bbd59bcefc.tar.gz |
- Remove the old insque() and remque() functions and their manual
page from the compatibility library.
- Add new implementations of insque() and remque() which conform to
IEEE Std 1003.1-2001 to libc. Add a new manual page for them and
connect them to the build.
- Add the prototypes of insque() and remque() to the search.h
header.
Diffstat (limited to 'lib/libc/stdlib/insque.c')
-rw-r--r-- | lib/libc/stdlib/insque.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/lib/libc/stdlib/insque.c b/lib/libc/stdlib/insque.c new file mode 100644 index 0000000..08d179a --- /dev/null +++ b/lib/libc/stdlib/insque.c @@ -0,0 +1,48 @@ +/* + * Initial implementation: + * Copyright (c) 2002 Robert Drehmel + * All rights reserved. + * + * As long as the above copyright statement and this notice remain + * unchanged, you can do what ever you want with this file. + * + * $FreeBSD$ + */ +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#define _SEARCH_PRIVATE +#include <search.h> +#ifdef DEBUG +#include <stdio.h> +#else +#include <stdlib.h> /* for NULL */ +#endif + +void insque(void *element, void *pred) +{ + struct que_elem *prev, *next, *elem; + + elem = (struct que_elem *)element; + prev = (struct que_elem *)pred; + + if (prev == NULL) { + elem->prev = elem->next = NULL; + return; + } + + next = prev->next; + if (next != NULL) { +#ifdef DEBUG + if (next->prev != prev) { + fprintf(stderr, "insque: Inconsistency detected:" + " next(%p)->prev(%p) != prev(%p)\n", + next, next->prev, prev); + } +#endif + next->prev = elem; + } + prev->next = elem; + elem->prev = prev; + elem->next = next; +} |