40 #if defined(DEBUG_MALLOC) && defined(DEBUG_MALLOC_LIST)
41 s_list_t* _ml_new(
const void *elem,
int line,
char *fi)
44 item = freewrlMalloc(line, fi,
sizeof(
s_list_t), TRUE);
45 ml_elem(item) = (
void *) elem;
53 ml_elem(item) = (
void *) elem;
79 if (!item)
return NULL;
112 list = ml_next(list);
124 if (ml_elem(list) == elem)
126 list = ml_next(list);
137 if (item) ml_next(item) = point;
140 if (!point || (list == point)) {
141 if (item) ml_next(item) = list;
144 prev = ml_prev(list, point);
146 ml_next(prev) = item;
147 ml_next(item) = point;
160 ml_next(ml_last(list)) = item;
173 prev = ml_prev(list, item);
175 ml_next(prev) = ml_next(item);
186 prev = ml_prev(list, item);
188 ml_next(prev) = ml_next(item);
196 *list = ml_insert(*list,*list,item);
200 item = ml_last(*list);
201 *list = ml_remove(*list,item);
225 ml_delete(list, item);
236 prev = ml_prev(list, item);
237 ml_next(prev) = ml_next(item);
241 ERROR_MSG(
"ml_delete2: *error* deleting empty item %p from list %p\n", item, list);
254 next = ml_next(list);
264 void ml_delete_all2(
s_list_t *list, f_free_t f)
275 ERROR_MSG(
"ml_delete_all2: *error* deleting empty item %p from list %p\n", list, begin);
277 next = ml_next(list);
294 list = ml_next(list);
302 TRACE_MSG(
"ml_dump (%p) : ", list);
303 ml_foreach(list, TRACE_MSG(
"%p ", __l));
309 TRACE_MSG(
"ml_dump_char (%p) : ", list);
310 ml_foreach(list, TRACE_MSG(
"%s ", (
char*)ml_elem(__l)));
338 cdl_elem(item) = (
void *) elem;
354 list = cdl_next(list);
355 }
while(list != head);
365 if(!head)
return NULL;
369 list = cdl_next(list);
370 }
while(list != head);
382 if(!list)
return NULL;
384 if (cdl_elem(list) == elem)
386 list = cdl_next(list);
387 }
while(list != head);
398 if(!item)
return head;
402 if(!point) tmp = item;
408 if(!point) point = head;
410 item->prev = point->prev;
412 item->prev->next = item;
427 last = cdl_prev(head);
450 ERROR_MSG(
"cdl_delete: no head or item\n");
454 if(item == head) ret = head->next;
455 if(head->next == head) ret = NULL;
457 prev = cdl_prev(item);
458 next = cdl_next(item);
476 ERROR_MSG(
"cdl_delete2: no head or item\n");
480 if(item == head) ret = head->next;
481 if(head->next == head) ret = NULL;
483 prev = cdl_prev(item);
484 next = cdl_next(item);
490 ERROR_MSG(
"cdl_delete2: *error* deleting empty item %p from list %p\n", item, head);
506 next = cdl_next(list);
509 }
while(list != head);
516 void cdl_delete_all2(
cd_list_t *head, f_free_t f)
525 if (cdl_elem(list)) {
528 ERROR_MSG(
"cdl_delete_all2: *error* deleting empty item %p from list %p\n", list, head);
530 next = cdl_next(list);
533 }
while(list != head);
550 list = cdl_next(list);
552 }
while(list != head);
558 TRACE_MSG(
"cdl_dump (%p) : ", head);
559 cdl_foreach(list, TRACE_MSG(
"%p ", __l));
565 TRACE_MSG(
"cdl_dump_char (%p) : ", head);
566 cdl_foreach(list, TRACE_MSG(
"%s ", (
char*)cdl_elem(__l)));