diff options
Diffstat (limited to 'src/list.c')
-rw-r--r-- | src/list.c | 84 |
1 files changed, 42 insertions, 42 deletions
@@ -1,4 +1,4 @@ -/* grecs - Gray's Extensible Configuration System +/* argot - Gray's Extensible Configuration System Copyright (C) 2007-2016 Sergey Poznyakoff Grecs is free software; you can redistribute it and/or modify it @@ -17,31 +17,31 @@ #ifdef HAVE_CONFIG_H # include <config.h> #endif -#include <grecs.h> -#include <grecs-gram.h> +#include <argot.h> +#include <argot-gram.h> #include <stdlib.h> #include <string.h> -struct grecs_list * -grecs_list_create() +struct argot_list * +argot_list_create() { - struct grecs_list *lp = grecs_malloc(sizeof(*lp)); + struct argot_list *lp = argot_malloc(sizeof(*lp)); memset(lp, 0, sizeof(*lp)); return lp; } size_t -grecs_list_size(struct grecs_list *lp) +argot_list_size(struct argot_list *lp) { return lp ? lp->count : 0; } void -grecs_list_insert_entry(struct grecs_list *lp, - struct grecs_list_entry *anchor, - struct grecs_list_entry *ent, int before) +argot_list_insert_entry(struct argot_list *lp, + struct argot_list_entry *anchor, + struct argot_list_entry *ent, int before) { - struct grecs_list_entry *p; + struct argot_list_entry *p; if (!anchor) { ent->prev = NULL; @@ -56,7 +56,7 @@ grecs_list_insert_entry(struct grecs_list *lp, } if (before) { - grecs_list_insert_entry(lp, anchor->prev, ent, 0); + argot_list_insert_entry(lp, anchor->prev, ent, 0); return; } @@ -71,9 +71,9 @@ grecs_list_insert_entry(struct grecs_list *lp, } void -grecs_list_remove_entry(struct grecs_list *lp, struct grecs_list_entry *ent) +argot_list_remove_entry(struct argot_list *lp, struct argot_list_entry *ent) { - struct grecs_list_entry *p; + struct argot_list_entry *p; if ((p = ent->prev)) p->next = ent->next; else @@ -82,20 +82,20 @@ grecs_list_remove_entry(struct grecs_list *lp, struct grecs_list_entry *ent) p->prev = ent->prev; else lp->tail = ent->prev; - grecs_free(ent); + argot_free(ent); lp->count--; } void -grecs_list_append(struct grecs_list *lp, void *val) +argot_list_append(struct argot_list *lp, void *val) { - struct grecs_list_entry *ep = grecs_malloc(sizeof(*ep)); + struct argot_list_entry *ep = argot_malloc(sizeof(*ep)); ep->data = val; - grecs_list_insert_entry(lp, lp->tail, ep, 0); + argot_list_insert_entry(lp, lp->tail, ep, 0); } void -grecs_list_add(struct grecs_list *dst, struct grecs_list *src) +argot_list_add(struct argot_list *dst, struct argot_list *src) { if (!src->head) return; @@ -112,50 +112,50 @@ grecs_list_add(struct grecs_list *dst, struct grecs_list *src) } void -grecs_list_push(struct grecs_list *lp, void *val) +argot_list_push(struct argot_list *lp, void *val) { - struct grecs_list_entry *ep = grecs_malloc(sizeof(*ep)); + struct argot_list_entry *ep = argot_malloc(sizeof(*ep)); ep->data = val; - grecs_list_insert_entry(lp, NULL, ep, 0); + argot_list_insert_entry(lp, NULL, ep, 0); } void * -grecs_list_pop(struct grecs_list *lp) +argot_list_pop(struct argot_list *lp) { void *data; - struct grecs_list_entry *ep = lp->head; + struct argot_list_entry *ep = lp->head; if (ep) { data = ep->data; - grecs_list_remove_entry(lp, ep); + argot_list_remove_entry(lp, ep); } else data = NULL; return data; } void * -grecs_list_remove_tail(struct grecs_list *lp) +argot_list_remove_tail(struct argot_list *lp) { void *data; - struct grecs_list_entry *ep; + struct argot_list_entry *ep; if (!lp->tail) return NULL; ep = lp->tail; data = lp->tail->data; - grecs_list_remove_entry(lp, ep); + argot_list_remove_entry(lp, ep); return data; } void -grecs_list_clear(struct grecs_list *lp) +argot_list_clear(struct argot_list *lp) { - struct grecs_list_entry *ep = lp->head; + struct argot_list_entry *ep = lp->head; while (ep) { - struct grecs_list_entry *next = ep->next; + struct argot_list_entry *next = ep->next; if (lp->free_entry) lp->free_entry(ep->data); - grecs_free(ep); + argot_free(ep); ep = next; } lp->head = lp->tail = NULL; @@ -163,11 +163,11 @@ grecs_list_clear(struct grecs_list *lp) } void -grecs_list_free(struct grecs_list *lp) +argot_list_free(struct argot_list *lp) { if (lp) { - grecs_list_clear(lp); - grecs_free(lp); + argot_list_clear(lp); + argot_free(lp); } } @@ -178,9 +178,9 @@ _ptrcmp(const void *a, const void *b) } void * -grecs_list_locate(struct grecs_list *lp, void *data) +argot_list_locate(struct argot_list *lp, void *data) { - struct grecs_list_entry *ep; + struct argot_list_entry *ep; int (*cmp)(const void *, const void *) = lp->cmp ? lp->cmp : _ptrcmp; for (ep = lp->head; ep; ep = ep->next) { @@ -191,9 +191,9 @@ grecs_list_locate(struct grecs_list *lp, void *data) } void * -grecs_list_index(struct grecs_list *lp, size_t idx) +argot_list_index(struct argot_list *lp, size_t idx) { - struct grecs_list_entry *ep; + struct argot_list_entry *ep; for (ep = lp->head; ep && idx; ep = ep->next, idx--) ; @@ -201,9 +201,9 @@ grecs_list_index(struct grecs_list *lp, size_t idx) } int -grecs_list_compare(struct grecs_list *a, struct grecs_list *b) +argot_list_compare(struct argot_list *a, struct argot_list *b) { - struct grecs_list_entry *ap, *bp; + struct argot_list_entry *ap, *bp; int (*cmp)(const void *, const void *); if (!a) @@ -211,7 +211,7 @@ grecs_list_compare(struct grecs_list *a, struct grecs_list *b) else if (!b) return 1; - if (grecs_list_size(a) != grecs_list_size(b)) + if (argot_list_size(a) != argot_list_size(b)) return 1; if (a->cmp != b->cmp) return 1; |