30#define DISABLE_DEBUGLOG
34#include <gwenhywfar/misc.h>
35#include <gwenhywfar/debug.h>
88 if (--(lp->refCount)==0) {
100 assert(lp->refCount);
113 GWEN_LIST_ENTRY *nle;
135 GWEN_LIST_ENTRY *nle;
141 nle->previous=nlp->last;
148 nle->linkCount=le->linkCount;
195 nl->listPtr=l->listPtr;
205 return l->refPtrInfo;
226 if (l->listPtr->refCount>1) {
238 le->previous=lp->last;
262 if (l->listPtr->refCount>1) {
276 lp->first->previous=le;
297 if (l->listPtr->first)
308 if (l->listPtr->first)
309 return l->listPtr->first->dataPtr;
319 if (l->listPtr->last)
330 if (l->listPtr->last)
331 return l->listPtr->last->dataPtr;
341 return l->listPtr->size;
357 if (l->listPtr->last==0)
359 if (l->listPtr->refCount>1) {
372 lp->last=le->previous;
374 le->previous->next=0;
394 if (l->listPtr->first==0)
396 if (l->listPtr->refCount>1) {
411 le->next->previous=0;
429 if (l->listPtr->refCount>1) {
455 el=fn(el, user_data);
470 if (l->listPtr->refCount>1) {
484 GWEN_LIST_ENTRY *current;
489 if (l->listPtr->refCount>1) {
490 GWEN_LIST_ENTRY *tle;
498 while (tle->previous) {
509 tle=l->listPtr->first;
522 if (it->current->linkCount==1) {
524 if (lp->first==current)
525 lp->first=current->next;
526 if (lp->last==current)
527 lp->last=current->previous;
531 it->current=current->next;
532 current->next->usage++;
533 current->next->previous=current->previous;
538 if (current->previous)
539 current->previous->next=current->next;
551 it->current=current->next;
552 current->next->usage++;
557 it->current->linkCount--;
619 if (l->listPtr->first==0)
622 li->current=l->listPtr->first;
624 li->current->usage++;
637 if (l->listPtr->last==0)
640 li->current=l->listPtr->last;
642 li->current->usage++;
653 fprintf(f,
"List contains %d entries\n", l->listPtr->size);
654 le=l->listPtr->first;
656 for (i=0; i<indent; i++)
658 fprintf(f,
"List entry %p\n", (
void *)le);
659 for (i=0; i<indent; i++)
661 fprintf(f,
" Usage : %d\n", le->usage);
662 for (i=0; i<indent; i++)
664 fprintf(f,
" Previous: %p\n", (
void *)le->previous);
665 for (i=0; i<indent; i++)
667 fprintf(f,
" Next : %p\n", (
void *)le->next);
668 for (i=0; i<indent; i++)
784 return li->current->dataPtr;
795 li->current->linkCount++;
805 return li->current->linkCount;
917 el = fn(el, user_data);
#define DBG_VERBOUS(dbg_logger, format, args...)
#define GWEN_INHERIT_FUNCTIONS(t)
#define GWEN_INHERIT_INIT(t, element)
#define GWEN_INHERIT_FINI(t, element)
const void *(* GWEN_CONSTLIST_FOREACH_CB)(const void *element, void *user_data)
struct GWEN_LIST GWEN_CONSTLIST
Doubly-linked list with const objects.
struct GWEN_LIST GWEN_LIST
Doubly-linked list.
struct GWEN_LIST_ITERATOR GWEN_LIST_ITERATOR
struct GWEN_LIST_ITERATOR GWEN_CONSTLIST_ITERATOR
void *(* GWEN_LIST_FOREACH_CB)(void *element, void *user_data)
#define GWEN_FREE_OBJECT(varname)
#define GWEN_NEW_OBJECT(typ, varname)
GWEN_REFPTR * GWEN_RefPtr_new(void *dp, GWEN_REFPTR_INFO *rpi)
void GWEN_RefPtr_free(GWEN_REFPTR *rp)
void * GWEN_RefPtr_GetData(const GWEN_REFPTR *rp)
void GWEN_RefPtrInfo_free(GWEN_REFPTR_INFO *rpi)
GWEN_REFPTR * GWEN_RefPtr_dup(const GWEN_REFPTR *rp)
void GWEN_RefPtrInfo_Attach(GWEN_REFPTR_INFO *rpi)
struct GWEN_REFPTR_INFO GWEN_REFPTR_INFO
struct GWEN_REFPTR GWEN_REFPTR
const void * GWEN_ConstListIterator_Data(GWEN_CONSTLIST_ITERATOR *li)
void GWEN__ListPtr_free(GWEN__LISTPTR *lp)
void GWEN_ConstList_PopFront(GWEN_CONSTLIST *l)
GWEN_LIST * GWEN_List_dup(const GWEN_LIST *l)
void GWEN_List_PushBackRefPtr(GWEN_LIST *l, GWEN_REFPTR *rp)
GWEN_LIST_ITERATOR * GWEN_ListIterator_new(const GWEN_LIST *l)
GWEN_LIST_ITERATOR * GWEN_List_Last(const GWEN_LIST *l)
void GWEN_ConstList_PushFront(GWEN_CONSTLIST *l, const void *p)
void GWEN_ConstList_Clear(GWEN_CONSTLIST *l)
void GWEN_ConstList_free(GWEN_CONSTLIST *l)
GWEN_LIST_ENTRY * GWEN_ListEntry_new(void)
void GWEN_List_SetRefPtrInfo(GWEN_LIST *l, GWEN_REFPTR_INFO *rpi)
void GWEN_List_PopFront(GWEN_LIST *l)
GWEN_LIST * GWEN_List_new(void)
GWEN_LIST_ITERATOR * GWEN_List_FindIter(GWEN_LIST *l, const void *p)
GWEN_CONSTLIST_ITERATOR * GWEN_ConstList_Last(const GWEN_CONSTLIST *l)
const void * GWEN_ConstListIterator_Next(GWEN_CONSTLIST_ITERATOR *li)
void GWEN_ConstListIterator_free(GWEN_CONSTLIST_ITERATOR *li)
void * GWEN_List_ForEach(GWEN_LIST *l, GWEN_LIST_FOREACH_CB fn, void *user_data)
GWEN__LISTPTR * GWEN__ListPtr_dup(GWEN__LISTPTR *lp)
GWEN_CONSTLIST * GWEN_ConstList_new(void)
const void * GWEN_ConstListIterator_Previous(GWEN_CONSTLIST_ITERATOR *li)
GWEN_LIST_ITERATOR * GWEN_List_First(const GWEN_LIST *l)
const void * GWEN_ConstList_GetFront(const GWEN_CONSTLIST *l)
void GWEN_ConstList_Erase(GWEN_CONSTLIST *l, GWEN_CONSTLIST_ITERATOR *it)
void GWEN__ListPtr_Attach(GWEN__LISTPTR *lp)
void GWEN_List_Dump(const GWEN_LIST *l, FILE *f, unsigned int indent)
GWEN_REFPTR * GWEN_ListIterator_DataRefPtr(GWEN_LIST_ITERATOR *li)
const void * GWEN_List_Contains(GWEN_LIST *l, const void *p)
void GWEN_List_Clear(GWEN_LIST *l)
void GWEN_ListIterator_free(GWEN_LIST_ITERATOR *li)
GWEN_CONSTLIST_ITERATOR * GWEN_ConstList_First(const GWEN_CONSTLIST *l)
int GWEN_List_IsEmpty(const GWEN_LIST *l)
void GWEN__ListPtr_Clear(GWEN__LISTPTR *lp)
void * GWEN_List_GetFront(const GWEN_LIST *l)
void GWEN_ListIterator_IncLinkCount(GWEN_LIST_ITERATOR *li)
void GWEN_List_Unshare(GWEN_LIST *l)
void * GWEN_List_GetBack(const GWEN_LIST *l)
const void * GWEN_ConstList_Contains(const GWEN_CONSTLIST *l, const void *p)
int GWEN_ConstList_IsEmpty(const GWEN_LIST *l)
void GWEN_List_free(GWEN_LIST *l)
GWEN_REFPTR * GWEN_ListIterator_NextRefPtr(GWEN_LIST_ITERATOR *li)
void GWEN_ConstList_Remove(GWEN_CONSTLIST *l, const void *p)
void * GWEN_ListIterator_Next(GWEN_LIST_ITERATOR *li)
GWEN_CONSTLIST_ITERATOR * GWEN_ConstListIterator_new(const GWEN_CONSTLIST *l)
GWEN__LISTPTR * GWEN__ListPtr_new(void)
void GWEN_ConstList_PopBack(GWEN_CONSTLIST *l)
void GWEN_List_PushFrontRefPtr(GWEN_LIST *l, GWEN_REFPTR *rp)
void GWEN_List_Erase(GWEN_LIST *l, GWEN_LIST_ITERATOR *it)
GWEN_REFPTR * GWEN_List_GetBackRefPtr(const GWEN_LIST *l)
void GWEN_ListEntry_free(GWEN_LIST_ENTRY *le)
void * GWEN_ListIterator_Previous(GWEN_LIST_ITERATOR *li)
void GWEN_List_PushFront(GWEN_LIST *l, void *p)
GWEN_REFPTR * GWEN_List_GetFrontRefPtr(const GWEN_LIST *l)
void GWEN_List_Remove(GWEN_LIST *l, const void *p)
void * GWEN_ListIterator_Data(GWEN_LIST_ITERATOR *li)
const void * GWEN_ConstList_GetBack(const GWEN_CONSTLIST *l)
unsigned int GWEN_List_GetSize(const GWEN_LIST *l)
unsigned int GWEN_ListIterator_GetLinkCount(const GWEN_LIST_ITERATOR *li)
const void * GWEN_ConstList_ForEach(GWEN_CONSTLIST *l, GWEN_CONSTLIST_FOREACH_CB fn, void *user_data)
unsigned int GWEN_ConstList_GetSize(const GWEN_CONSTLIST *l)
void GWEN_List_PopBack(GWEN_LIST *l)
GWEN_CONSTLIST_ITERATOR * GWEN_ConstList_FindIter(const GWEN_CONSTLIST *l, const void *p)
GWEN_REFPTR_INFO * GWEN_List_GetRefPtrInfo(const GWEN_LIST *l)
void GWEN_ConstList_PushBack(GWEN_CONSTLIST *l, const void *p)
GWEN_REFPTR * GWEN_ListIterator_PreviousRefPtr(GWEN_LIST_ITERATOR *li)
void GWEN_List_PushBack(GWEN_LIST *l, void *p)