00001 #ifndef __EKG_DYNSTUFF_INLINE_H
00002 #define __EKG_DYNSTUFF_INLINE_H
00003
00004
00005
00006 #include "dynstuff.h"
00007
00008 #define __DYNSTUFF_LIST_ADD(lista, typ, __notused) \
00009 void lista##_add(typ *new) { list_add3((list_t *) (void *) &lista, (list_t) new); }
00010
00011 #define __DYNSTUFF_LIST_ADD_BEGINNING(lista, typ, __notused) \
00012 void lista##_add(typ *new) { list_add_beginning3((list_t *) (void *) &lista, (list_t) new); }
00013
00014 #define __DYNSTUFF_LIST_ADD_SORTED(lista, typ, comparision) \
00015 void lista##_add(typ *new) { list_add_sorted3((list_t *) (void *) &lista, (list_t) new, (void *) comparision); }
00016
00017 #define __DYNSTUFF_LIST_REMOVE_SAFE(lista, typ, free_func) \
00018 void lista##_remove(typ *elem) { list_remove3((list_t *) (void *) &lista, (list_t) elem, (void *) free_func); }
00019
00020 #define __DYNSTUFF_LIST_REMOVE_ITER(lista, typ, free_func) \
00021 typ *lista##_removei(typ *elem) { return list_remove3i((list_t *) (void *) &lista, (list_t) elem, (void *) free_func); }
00022
00023 #define __DYNSTUFF_LIST_DESTROY(lista, typ, free_func) \
00024 void lista##_destroy(void) { list_destroy3((list_t) lista, (void *) free_func); lista = NULL; }
00025
00026
00027
00028 #define __DYNSTUFF_ADD(prefix, typ, __notused) \
00029 void prefix##_add(typ **lista, typ *new) { list_add3((list_t *) lista, (list_t) new); }
00030
00031 #define __DYNSTUFF_ADD_BEGINNING(prefix, typ, __notused) \
00032 void prefix##_add(typ **lista, typ *new) { list_add_beginning3((list_t *) lista, (list_t) new); }
00033
00034 #define __DYNSTUFF_ADD_SORTED(prefix, typ, comparision) \
00035 void prefix##_add(typ **lista, typ *new) { list_add_sorted3((list_t *) lista, (list_t) new, (void *) comparision); }
00036
00037 #define __DYNSTUFF_REMOVE_SAFE(prefix, typ, free_func) \
00038 void prefix##_remove(typ **lista, typ *elem) { \
00039 list_remove3((list_t *) lista, (list_t) elem, (void *) free_func); \
00040 }
00041
00042 #define __DYNSTUFF_DESTROY(prefix, typ, free_func) \
00043 void prefix##_destroy(typ **lista) { \
00044 list_destroy3((list_t) *lista, (void *) free_func); \
00045 *lista = NULL; \
00046 }
00047
00048 #define __DYNSTUFF_NOREMOVE(lista, typ, free_func)
00049 #define __DYNSTUFF_NOUNLINK(lista, typ)
00050 #define __DYNSTUFF_NOCOUNT(lista, typ)
00051 #define __DYNSTUFF_NODESTROY(lista, typ, free_func)
00052
00053 #define DYNSTUFF_LIST_DECLARE_FULL(lista, type, compare_func, free_func, list_add, list_remove, list_remove2, list_unlink, list_destroy, list_count) \
00054 list_add(lista, type, compare_func) \
00055 list_remove(lista, type, free_func) \
00056 list_remove2(lista, type, free_func) \
00057 list_unlink(lista, type) \
00058 list_destroy(lista, type, free_func) \
00059 list_count(lista, type)
00060
00061 #define DYNSTUFF_LIST_DECLARE(lista, type, free_func, list_add, list_remove, list_destroy) \
00062 DYNSTUFF_LIST_DECLARE_WC(lista, type, free_func, list_add, list_remove, list_destroy, __DYNSTUFF_NOCOUNT)
00063
00064 #define DYNSTUFF_LIST_DECLARE_NF(lista, type, list_add, list_unlink) \
00065 DYNSTUFF_LIST_DECLARE_FULL(lista, type, NULL, NULL, list_add, __DYNSTUFF_NOREMOVE, __DYNSTUFF_NOREMOVE, list_unlink, __DYNSTUFF_NODESTROY, __DYNSTUFF_NOCOUNT)
00066
00067 #define DYNSTUFF_LIST_DECLARE_WC(lista, type, free_func, list_add, list_remove, list_destroy, list_count) \
00068 DYNSTUFF_LIST_DECLARE_FULL(lista, type, NULL, free_func, list_add, list_remove, __DYNSTUFF_NOREMOVE, __DYNSTUFF_NOUNLINK, list_destroy, list_count)
00069
00070 #define DYNSTUFF_LIST_DECLARE_SORTED(lista, type, compare_func, free_func, list_add, list_remove, list_destroy) \
00071 DYNSTUFF_LIST_DECLARE_FULL(lista, type, compare_func, free_func, list_add, list_remove, __DYNSTUFF_NOREMOVE, __DYNSTUFF_NOUNLINK, list_destroy, __DYNSTUFF_NOCOUNT)
00072
00073
00074 #define DYNSTUFF_LIST_DECLARE2(lista, type, free_func, list_add, list_remove, list_remove2, list_destroy) \
00075 DYNSTUFF_LIST_DECLARE_FULL(lista, type, NULL, free_func, list_add, list_remove, list_remove2, __DYNSTUFF_NOUNLINK, list_destroy, __DYNSTUFF_NOCOUNT)
00076
00077 #define DYNSTUFF_LIST_DECLARE2_SORTED(lista, type, compare_func, free_func, list_add, list_remove, list_remove2, list_destroy) \
00078 DYNSTUFF_LIST_DECLARE_FULL(lista, type, compare_func, free_func, list_add, list_remove, list_remove2, __DYNSTUFF_NOUNLINK, list_destroy, __DYNSTUFF_NOCOUNT)
00079
00080 #define DYNSTUFF_LIST_DECLARE_SORTED_NF(lista, type, compare_func, list_add, list_unlink) \
00081 DYNSTUFF_LIST_DECLARE_FULL(lista, type, compare_func, NULL, list_add, __DYNSTUFF_NOREMOVE, __DYNSTUFF_NOREMOVE, list_unlink, __DYNSTUFF_NODESTROY, __DYNSTUFF_NOCOUNT)
00082
00083
00084 #endif