xref: /third_party/musl/src/search/insque.c
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/musl/src/search/
1570af302Sopenharmony_ci#include <search.h>
2570af302Sopenharmony_ci
3570af302Sopenharmony_cistruct node {
4570af302Sopenharmony_ci	struct node *next;
5570af302Sopenharmony_ci	struct node *prev;
6570af302Sopenharmony_ci};
7570af302Sopenharmony_ci
8570af302Sopenharmony_civoid insque(void *element, void *pred)
9570af302Sopenharmony_ci{
10570af302Sopenharmony_ci	struct node *e = element;
11570af302Sopenharmony_ci	struct node *p = pred;
12570af302Sopenharmony_ci
13570af302Sopenharmony_ci	if (!p) {
14570af302Sopenharmony_ci		e->next = e->prev = 0;
15570af302Sopenharmony_ci		return;
16570af302Sopenharmony_ci	}
17570af302Sopenharmony_ci	e->next = p->next;
18570af302Sopenharmony_ci	e->prev = p;
19570af302Sopenharmony_ci	p->next = e;
20570af302Sopenharmony_ci	if (e->next)
21570af302Sopenharmony_ci		e->next->prev = e;
22570af302Sopenharmony_ci}
23570af302Sopenharmony_ci
24570af302Sopenharmony_civoid remque(void *element)
25570af302Sopenharmony_ci{
26570af302Sopenharmony_ci	struct node *e = element;
27570af302Sopenharmony_ci
28570af302Sopenharmony_ci	if (e->next)
29570af302Sopenharmony_ci		e->next->prev = e->prev;
30570af302Sopenharmony_ci	if (e->prev)
31570af302Sopenharmony_ci		e->prev->next = e->next;
32570af302Sopenharmony_ci}
33

Indexes created Thu Nov 07 10:32:03 CST 2024