author | Tero Marttila <terom@fixme.fi> |
Thu, 21 May 2009 16:57:56 +0300 | |
changeset 213 | f0e52e026197 |
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; }