author | Tero Marttila <terom@fixme.fi> |
Wed, 27 May 2009 23:57:48 +0300 | |
branch | new-lib-errors |
changeset 217 | 7728d6ec3abf |
parent 171 | b54f393c3df0 |
permissions | -rw-r--r-- |
#include "chain.h" #include <stdlib.h> #include <assert.h> void *_chain_add (struct _chain_head *head, bool tail, size_t size) { struct _chain_item *item; // sanity-check assert(size >= sizeof(item)); // allocate the chain item if ((item = calloc(1, size)) == NULL) return NULL; // insert if (tail) TAILQ_INSERT_TAIL(head, item, _chain_list); else TAILQ_INSERT_HEAD(head, item, _chain_list); // ok return item; }