Mercurial > MadButterfly
view src/tools.h @ 20:74d3d5dc9aaa
rename XXX_draw() to XXX_fill()
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Sat, 02 Aug 2008 15:46:26 +0800 |
parents | ed55009d96d3 |
children | db2aa914e14b |
line wrap: on
line source
#ifndef __TOOLS_H_ #define __TOOLS_H_ typedef struct _elmpool elmpool_t; extern elmpool_t *elmpool_new(int elm_sz, int inc_num); extern void *elmpool_elm_alloc(elmpool_t *pool); extern void elmpool_elm_free(elmpool_t *pool, void *elm); extern void elmpool_free(elmpool_t *pool); #define STAILQ(type) \ struct { \ type *head; \ type *tail; \ } #define STAILQ_INIT(q) \ do { \ (q).head = (q).tail = NULL; \ } while(0) #define STAILQ_CLEAN(q) STAILQ_INIT(q) #define STAILQ_HEAD(q) ((q).head) #define STAILQ_TAIL(q) ((q).tail) #define STAILQ_NEXT(type, field, elm) ((elm)->field) #define STAILQ_INS(q, type, field, elm) \ do { \ (elm)->field = (q).head; \ (q).head = elm; \ if((q).tail == NULL) \ (q).tail = elm; \ } while(0) #define STAILQ_INS_TAIL(q, type, field, elm) \ do { \ (elm)->field = NULL; \ if((q).tail != NULL) \ (q).tail->field = elm; \ (q).tail = elm; \ if((q).head == NULL) \ (q).head = elm; \ } while(0) #define STAILQ_REMOVE(q, type, field, elm) \ do { \ if((elm) == (q).head) { \ (q).head = (elm)->field; \ if((q).head == NULL) \ (q).tail = NULL; \ } else { \ type *_stailq_cur = (q).head; \ while(_stailq_cur != NULL && \ _stailq_cur->field != (elm)) \ _stailq_cur = _stailq_cur->field; \ if(_stailq_cur != NULL) { \ _stailq_cur->field = elm; \ if((q).tail == (elm)) \ (q).tail = _stailq_cur; \ } \ } \ } while(0) #endif /* __TOOLS_H_ */