30 #define DISABLE_DEBUGLOG
34 #include <gwenhywfar/misc.h>
35 #include <gwenhywfar/debug.h>
84 if (--(lp->refCount)==0) {
107 GWEN_LIST_ENTRY *nle;
128 GWEN_LIST_ENTRY *nle;
134 nle->previous=nlp->last;
141 nle->linkCount=le->linkCount;
185 nl->listPtr=l->listPtr;
194 return l->refPtrInfo;
213 if (l->listPtr->refCount>1) {
225 le->previous=lp->last;
247 if (l->listPtr->refCount>1) {
261 lp->first->previous=le;
280 if (l->listPtr->first)
290 if (l->listPtr->first)
291 return l->listPtr->first->dataPtr;
300 if (l->listPtr->last)
310 if (l->listPtr->last)
311 return l->listPtr->last->dataPtr;
320 return l->listPtr->size;
334 if (l->listPtr->last==0)
336 if (l->listPtr->refCount>1) {
349 lp->last=le->previous;
351 le->previous->next=0;
370 if (l->listPtr->first==0)
372 if (l->listPtr->refCount>1) {
387 le->next->previous=0;
404 if (l->listPtr->refCount>1) {
429 el=fn(el, user_data);
443 if (l->listPtr->refCount>1) {
456 GWEN_LIST_ENTRY *current;
461 if (l->listPtr->refCount>1) {
462 GWEN_LIST_ENTRY *tle;
470 while(tle->previous) {
481 tle=l->listPtr->first;
494 if (it->current->linkCount==1) {
496 if (lp->first==current)
497 lp->first=current->next;
498 if (lp->last==current)
499 lp->last=current->previous;
503 it->current=current->next;
504 current->next->usage++;
505 current->next->previous=current->previous;
510 if (current->previous)
511 current->previous->next=current->next;
523 it->current=current->next;
524 current->next->usage++;
529 it->current->linkCount--;
587 if (l->listPtr->first==0)
590 li->current=l->listPtr->first;
592 li->current->usage++;
604 if (l->listPtr->last==0)
607 li->current=l->listPtr->last;
609 li->current->usage++;
619 fprintf(f,
"List contains %d entries\n", l->listPtr->size);
620 le=l->listPtr->first;
622 for (i=0; i<indent; i++) fprintf(f,
" ");
623 fprintf(f,
"List entry %p\n", (
void*)le);
624 for (i=0; i<indent; i++) fprintf(f,
" ");
625 fprintf(f,
" Usage : %d\n", le->usage);
626 for (i=0; i<indent; i++) fprintf(f,
" ");
627 fprintf(f,
" Previous: %p\n", (
void*)le->previous);
628 for (i=0; i<indent; i++) fprintf(f,
" ");
629 fprintf(f,
" Next : %p\n", (
void*)le->next);
630 for (i=0; i<indent; i++) fprintf(f,
" ");
737 return li->current->dataPtr;
747 li->current->linkCount++;
756 return li->current->linkCount;
855 el = fn(el, user_data);
GWEN_REFPTR_INFO * GWEN_List_GetRefPtrInfo(const GWEN_LIST *l)
void GWEN_List_PushBackRefPtr(GWEN_LIST *l, GWEN_REFPTR *rp)
GWEN_REFPTR * GWEN_ListIterator_PreviousRefPtr(GWEN_LIST_ITERATOR *li)
const void * GWEN_ConstListIterator_Data(GWEN_CONSTLIST_ITERATOR *li)
GWEN__LISTPTR * GWEN__ListPtr_dup(GWEN__LISTPTR *lp)
void GWEN_ConstList_PushBack(GWEN_CONSTLIST *l, const void *p)
const void * GWEN_List_Contains(GWEN_LIST *l, const void *p)
void GWEN_ConstList_PushFront(GWEN_CONSTLIST *l, const void *p)
#define GWEN_INHERIT_FINI(t, element)
struct GWEN_LIST_ITERATOR GWEN_LIST_ITERATOR
GWEN_CONSTLIST_ITERATOR * GWEN_ConstList_First(const GWEN_CONSTLIST *l)
GWEN_REFPTR * GWEN_ListIterator_DataRefPtr(GWEN_LIST_ITERATOR *li)
void GWEN_List_Erase(GWEN_LIST *l, GWEN_LIST_ITERATOR *it)
void GWEN_ConstList_Clear(GWEN_CONSTLIST *l)
void GWEN_List_PopBack(GWEN_LIST *l)
GWEN_LIST_ITERATOR * GWEN_List_Last(const GWEN_LIST *l)
void GWEN_ConstList_PopBack(GWEN_CONSTLIST *l)
void GWEN_RefPtrInfo_free(GWEN_REFPTR_INFO *rpi)
GWEN_LIST_ITERATOR * GWEN_List_First(const GWEN_LIST *l)
void GWEN_List_SetRefPtrInfo(GWEN_LIST *l, GWEN_REFPTR_INFO *rpi)
#define GWEN_FREE_OBJECT(varname)
GWEN__LISTPTR * GWEN__ListPtr_new(void)
#define DBG_VERBOUS(dbg_logger, format, args...)
void * GWEN_List_GetBack(const GWEN_LIST *l)
void GWEN__ListPtr_free(GWEN__LISTPTR *lp)
const void *(* GWEN_CONSTLIST_FOREACH_CB)(const void *element, void *user_data)
void GWEN_List_Dump(const GWEN_LIST *l, FILE *f, unsigned int indent)
void GWEN_RefPtrInfo_Attach(GWEN_REFPTR_INFO *rpi)
unsigned int GWEN_ConstList_GetSize(const GWEN_CONSTLIST *l)
void GWEN_ConstList_PopFront(GWEN_CONSTLIST *l)
void GWEN_ConstList_free(GWEN_CONSTLIST *l)
void * GWEN_ListIterator_Previous(GWEN_LIST_ITERATOR *li)
void *(* GWEN_LIST_FOREACH_CB)(void *element, void *user_data)
struct GWEN_REFPTR GWEN_REFPTR
GWEN_REFPTR * GWEN_RefPtr_new(void *dp, GWEN_REFPTR_INFO *rpi)
const void * GWEN_ConstListIterator_Next(GWEN_CONSTLIST_ITERATOR *li)
void * GWEN_List_GetFront(const GWEN_LIST *l)
GWEN_LIST * GWEN_List_new(void)
void GWEN_ListIterator_IncLinkCount(GWEN_LIST_ITERATOR *li)
#define GWEN_NEW_OBJECT(typ, varname)
void GWEN_ListIterator_free(GWEN_LIST_ITERATOR *li)
void GWEN_RefPtr_free(GWEN_REFPTR *rp)
GWEN_LIST * GWEN_List_dup(const GWEN_LIST *l)
void GWEN_ConstListIterator_free(GWEN_CONSTLIST_ITERATOR *li)
struct GWEN_LIST GWEN_LIST
Doubly-linked list.
struct GWEN_REFPTR_INFO GWEN_REFPTR_INFO
void GWEN_List_free(GWEN_LIST *l)
GWEN_REFPTR * GWEN_List_GetBackRefPtr(const GWEN_LIST *l)
GWEN_LIST_ENTRY * GWEN_ListEntry_new(void)
const void * GWEN_ConstList_GetFront(const GWEN_CONSTLIST *l)
void GWEN__ListPtr_Attach(GWEN__LISTPTR *lp)
void GWEN_List_Clear(GWEN_LIST *l)
#define GWEN_INHERIT_INIT(t, element)
void GWEN_ListEntry_free(GWEN_LIST_ENTRY *le)
void * GWEN_List_ForEach(GWEN_LIST *l, GWEN_LIST_FOREACH_CB fn, void *user_data)
GWEN_REFPTR * GWEN_RefPtr_dup(const GWEN_REFPTR *rp)
void GWEN__ListPtr_Clear(GWEN__LISTPTR *lp)
const void * GWEN_ConstListIterator_Previous(GWEN_CONSTLIST_ITERATOR *li)
GWEN_REFPTR * GWEN_List_GetFrontRefPtr(const GWEN_LIST *l)
void GWEN_ConstList_Erase(GWEN_CONSTLIST *l, GWEN_CONSTLIST_ITERATOR *it)
void GWEN_List_PushFront(GWEN_LIST *l, void *p)
void GWEN_List_PopFront(GWEN_LIST *l)
struct GWEN_LIST_ITERATOR GWEN_CONSTLIST_ITERATOR
void * GWEN_ListIterator_Data(GWEN_LIST_ITERATOR *li)
int GWEN_List_IsEmpty(const GWEN_LIST *l)
const void * GWEN_ConstList_Contains(const GWEN_CONSTLIST *l, const void *p)
unsigned int GWEN_ListIterator_GetLinkCount(const GWEN_LIST_ITERATOR *li)
unsigned int GWEN_List_GetSize(const GWEN_LIST *l)
void * GWEN_RefPtr_GetData(const GWEN_REFPTR *rp)
GWEN_CONSTLIST * GWEN_ConstList_new(void)
void GWEN_List_PushFrontRefPtr(GWEN_LIST *l, GWEN_REFPTR *rp)
int GWEN_ConstList_IsEmpty(const GWEN_LIST *l)
void GWEN_List_Unshare(GWEN_LIST *l)
GWEN_LIST_ITERATOR * GWEN_ListIterator_new(const GWEN_LIST *l)
void GWEN_ConstList_Remove(GWEN_CONSTLIST *l, const void *p)
GWEN_CONSTLIST_ITERATOR * GWEN_ConstListIterator_new(const GWEN_CONSTLIST *l)
const void * GWEN_ConstList_GetBack(const GWEN_CONSTLIST *l)
void GWEN_List_Remove(GWEN_LIST *l, const void *p)
GWEN_LIST_ITERATOR * GWEN_List_FindIter(GWEN_LIST *l, const void *p)
GWEN_REFPTR * GWEN_ListIterator_NextRefPtr(GWEN_LIST_ITERATOR *li)
struct GWEN_LIST GWEN_CONSTLIST
Doubly-linked list with const objects.
GWEN_CONSTLIST_ITERATOR * GWEN_ConstList_Last(const GWEN_CONSTLIST *l)
#define GWEN_INHERIT_FUNCTIONS(t)
void GWEN_List_PushBack(GWEN_LIST *l, void *p)
void * GWEN_ListIterator_Next(GWEN_LIST_ITERATOR *li)
GWEN_CONSTLIST_ITERATOR * GWEN_ConstList_FindIter(const GWEN_CONSTLIST *l, const void *p)
const void * GWEN_ConstList_ForEach(GWEN_CONSTLIST *l, GWEN_CONSTLIST_FOREACH_CB fn, void *user_data)