Idź do dokumentacji tego pliku. 1 #ifndef __EKG_DYNSTUFF_INLINE_H 2 #define __EKG_DYNSTUFF_INLINE_H 6 #define DYNSTUFF_USE_LIST3 1 16 #if DYNSTUFF_USE_LIST3 18 #define __DYNSTUFF_LIST_ADD(lista, typ, __notused) \ 19 void lista##_add(typ *new_) { list_add3((list_t *) (void *) &lista, (list_t) new_); } 21 #define __DYNSTUFF_LIST_ADD_BEGINNING(lista, typ, __notused) \ 22 void lista##_add(typ *new_) { list_add_beginning3((list_t *) (void *) &lista, (list_t) new_); } 24 #define __DYNSTUFF_LIST_ADD_SORTED(lista, typ, comparision) \ 25 void lista##_add(typ *new_) { list_add_sorted3((list_t *) (void *) &lista, (list_t) new_, (void *) comparision); } 27 #define __DYNSTUFF_LIST_REMOVE_SAFE(lista, typ, free_func) \ 28 void lista##_remove(typ *elem) { list_remove3((list_t *) (void *) &lista, (list_t) elem, (void *) free_func); } 30 #define __DYNSTUFF_LIST_REMOVE_ITER(lista, typ, free_func) \ 31 typ *lista##_removei(typ *elem) { return list_remove3i((list_t *) (void *) &lista, (list_t) elem, (void *) free_func); } 33 #define __DYNSTUFF_LIST_UNLINK(lista, typ) \ 34 void lista##_unlink(typ *elem) { list_unlink3((list_t *) (void *) &lista, (list_t) elem); } 36 #define __DYNSTUFF_LIST_DESTROY(lista, typ, free_func) \ 37 void lista##_destroy(void) { list_destroy3((list_t) lista, (void *) free_func); lista = NULL; } 39 #define __DYNSTUFF_LIST_COUNT(lista, typ) \ 40 int lista##_count(void) { return list_count((list_t) lista); } 44 #define __DYNSTUFF_LIST_ADD(lista, typ, __notused) \ 45 void lista##_add(typ *new_) { \ 58 #define __DYNSTUFF_LIST_ADD_BEGINNING(lista, typ, __notused) \ 59 void lista##_add(typ *new_) { \ 64 #define __DYNSTUFF_LIST_ADD_SORTED(lista, typ, comparision) \ 65 void lista##_add(typ *new_) { \ 73 while (comparision(new_, tmp) > 0) { \ 90 #define __DYNSTUFF_LIST_REMOVE_SAFE(lista, typ, free_func) \ 91 void lista##_remove(typ *elem) { \ 96 lista = lista->next; \ 98 typ *tmp, *last = lista; \ 100 for (tmp = lista->next; tmp; tmp = tmp->next) { \ 103 if (tmp->next == NULL) { \ 109 last->next = tmp->next; \ 116 #define __DYNSTUFF_LIST_REMOVE_ITER(lista, typ, free_func) \ 117 typ *lista##_removei(typ *elem) { \ 120 if (lista == elem) { \ 121 lista = lista->next; \ 122 ret = (typ *) &lista; \ 124 typ *tmp, *last = lista; \ 126 for (tmp = lista->next; tmp; tmp = tmp->next) { \ 131 last->next = tmp->next; \ 140 #define __DYNSTUFF_LIST_UNLINK(lista, typ) \ 141 void lista##_unlink(typ *elem) { \ 146 lista = lista->next; \ 148 typ *tmp, *last = lista; \ 150 for (tmp = lista->next; tmp; tmp = tmp->next) { \ 153 if (tmp->next == NULL) { \ 159 last->next = tmp->next; \ 163 #define __DYNSTUFF_LIST_DESTROY(lista, typ, free_func) \ 164 void lista##_destroy(void) { \ 168 lista = lista->next; \ 177 #define __DYNSTUFF_LIST_COUNT(lista, typ) \ 178 int lista##_count(void) { \ 182 for (list = lista; list; list = list->next) \ 191 #if DYNSTUFF_USE_LIST3 193 #define __DYNSTUFF_ADD(prefix, typ, __notused) \ 194 void prefix##_add(typ **lista, typ *new_) { list_add3((list_t *) lista, (list_t) new_); } 196 #define __DYNSTUFF_ADD_BEGINNING(prefix, typ, __notused) \ 197 void prefix##_add(typ **lista, typ *new_) { list_add_beginning3((list_t *) lista, (list_t) new_); } 199 #define __DYNSTUFF_ADD_SORTED(prefix, typ, comparision) \ 200 void prefix##_add(typ **lista, typ *new_) { list_add_sorted3((list_t *) lista, (list_t) new_, (void *) comparision); } 202 #define __DYNSTUFF_REMOVE_SAFE(prefix, typ, free_func) \ 203 void prefix##_remove(typ **lista, typ *elem) { \ 204 list_remove3((list_t *) lista, (list_t) elem, (void *) free_func); \ 207 #define __DYNSTUFF_REMOVE_ITER(prefix, typ, free_func) \ 208 typ *prefix##_removei(typ **lista, typ *elem) { \ 209 return list_remove3i((list_t *) lista, (list_t) elem, (void *) free_func); \ 212 #define __DYNSTUFF_DESTROY(prefix, typ, free_func) \ 213 void prefix##_destroy(typ **lista) { \ 214 list_destroy3((list_t) *lista, (void *) free_func); \ 218 #define __DYNSTUFF_COUNT(prefix, typ) \ 219 int prefix##_count(typ *lista) { \ 220 return list_count((list_t) lista); \ 223 #define __DYNSTUFF_GET_NTH(prefix, typ) \ 224 typ *prefix##_get_nth(typ *lista, int id) { \ 225 return list_get_nth3((list_t) lista, id); \ 231 #define __DYNSTUFF_ADD(prefix, typ, __notused) \ 232 void prefix##_add(typ **lista, typ *new_) { \ 236 if (!(tmp = *lista)) { \ 245 #define __DYNSTUFF_ADD_BEGINNING(prefix, typ, __notused) \ 246 void prefix##_add(typ **lista, typ *new_) { \ 247 new_->next = *lista; \ 251 #define __DYNSTUFF_ADD_SORTED(prefix, typ, comparision) \ 252 void prefix##_add(typ **lista, typ *new_) { \ 256 if (!(tmp = *lista)) { \ 261 while (comparision(new_, tmp) > 0) { \ 269 new_->next = *lista; \ 278 #define __DYNSTUFF_REMOVE_SAFE(prefix, typ, free_func) \ 279 void prefix##_remove(typ **lista, typ *elem) { \ 280 if (!lista || !(*lista)) \ 283 if (*lista == elem) \ 284 *lista = (*lista)->next; \ 286 typ *tmp, *last = *lista; \ 288 for (tmp = (*lista)->next; tmp; tmp = tmp->next) { \ 291 if (tmp->next == NULL) { \ 297 last->next = tmp->next; \ 304 #define __DYNSTUFF_REMOVE_ITER(prefix, typ, free_func) \ 305 typ *prefix##_removei(typ **lista, typ *elem) { \ 308 if (*lista == elem) { \ 309 *lista = (*lista)->next; \ 310 ret = (typ *) lista; \ 312 typ *tmp, *last = *lista; \ 314 for (tmp = (*lista)->next; tmp; tmp = tmp->next) { \ 319 last->next = tmp->next; \ 328 #define __DYNSTUFF_UNLINK(prefix, typ) \ 329 void prefix##_unlink(typ **lista, typ *elem) { \ 330 if (!lista || !(*lista)) \ 333 if (*lista == elem) \ 334 *lista = (*lista)->next; \ 336 typ *tmp, *last = *lista; \ 338 for (tmp = (*lista)->next; tmp; tmp = tmp->next) { \ 341 if (tmp->next == NULL) { \ 347 last->next = tmp->next; \ 351 #define __DYNSTUFF_DESTROY(prefix, typ, free_func) \ 352 void prefix##_destroy(typ **lista) { \ 356 *lista = (*lista)->next; \ 365 #define __DYNSTUFF_COUNT(prefix, typ) \ 366 int prefix##_count(typ *list) { \ 369 for (; list; list = list->next) \ 374 #define __DYNSTUFF_GET_NTH(prefix, typ) \ 375 typ *prefix##_get_nth(typ *lista, int id) { \ 380 lista = lista->next; \ 387 #define __DYNSTUFF_NOREMOVE(lista, typ, free_func) 388 #define __DYNSTUFF_NOUNLINK(lista, typ) 389 #define __DYNSTUFF_NOCOUNT(lista, typ) 390 #define __DYNSTUFF_NODESTROY(lista, typ, free_func) 392 #define DYNSTUFF_LIST_DECLARE_FULL(lista, type, compare_func, free_func, list_add, list_remove, list_remove2, list_unlink, list_destroy, list_count) \ 393 list_add(lista, type, compare_func) \ 394 list_remove(lista, type, free_func) \ 395 list_remove2(lista, type, free_func) \ 396 list_unlink(lista, type) \ 397 list_destroy(lista, type, free_func) \ 398 list_count(lista, type) 400 #define DYNSTUFF_LIST_DECLARE(lista, type, free_func, list_add, list_remove, list_destroy) \ 401 DYNSTUFF_LIST_DECLARE_WC(lista, type, free_func, list_add, list_remove, list_destroy, __DYNSTUFF_NOCOUNT) 403 #define DYNSTUFF_LIST_DECLARE_NF(lista, type, list_add, list_unlink) \ 404 DYNSTUFF_LIST_DECLARE_FULL(lista, type, NULL, NULL, list_add, __DYNSTUFF_NOREMOVE, __DYNSTUFF_NOREMOVE, list_unlink, __DYNSTUFF_NODESTROY, __DYNSTUFF_NOCOUNT) 406 #define DYNSTUFF_LIST_DECLARE_WC(lista, type, free_func, list_add, list_remove, list_destroy, list_count) \ 407 DYNSTUFF_LIST_DECLARE_FULL(lista, type, NULL, free_func, list_add, list_remove, __DYNSTUFF_NOREMOVE, __DYNSTUFF_NOUNLINK, list_destroy, list_count) 409 #define DYNSTUFF_LIST_DECLARE_SORTED(lista, type, compare_func, free_func, list_add, list_remove, list_destroy) \ 410 DYNSTUFF_LIST_DECLARE_FULL(lista, type, compare_func, free_func, list_add, list_remove, __DYNSTUFF_NOREMOVE, __DYNSTUFF_NOUNLINK, list_destroy, __DYNSTUFF_NOCOUNT) 413 #define DYNSTUFF_LIST_DECLARE2(lista, type, free_func, list_add, list_remove, list_remove2, list_destroy) \ 414 DYNSTUFF_LIST_DECLARE_FULL(lista, type, NULL, free_func, list_add, list_remove, list_remove2, __DYNSTUFF_NOUNLINK, list_destroy, __DYNSTUFF_NOCOUNT) 416 #define DYNSTUFF_LIST_DECLARE2_SORTED(lista, type, compare_func, free_func, list_add, list_remove, list_remove2, list_destroy) \ 417 DYNSTUFF_LIST_DECLARE_FULL(lista, type, compare_func, free_func, list_add, list_remove, list_remove2, __DYNSTUFF_NOUNLINK, list_destroy, __DYNSTUFF_NOCOUNT) 419 #define DYNSTUFF_LIST_DECLARE_SORTED_NF(lista, type, compare_func, list_add, list_unlink) \ 420 DYNSTUFF_LIST_DECLARE_FULL(lista, type, compare_func, NULL, list_add, __DYNSTUFF_NOREMOVE, __DYNSTUFF_NOREMOVE, list_unlink, __DYNSTUFF_NODESTROY, __DYNSTUFF_NOCOUNT)