version 1.1, 2012/02/21 23:37:58
|
version 1.1.1.2, 2014/06/15 19:53:30
|
Line 94 xmlLinkCompare(const void *data0, const void *data1)
|
Line 94 xmlLinkCompare(const void *data0, const void *data1)
|
* |
* |
* Returns the link containing the data or NULL |
* Returns the link containing the data or NULL |
*/ |
*/ |
static xmlLinkPtr | static xmlLinkPtr |
xmlListLowerSearch(xmlListPtr l, void *data) | xmlListLowerSearch(xmlListPtr l, void *data) |
{ |
{ |
xmlLinkPtr lk; |
xmlLinkPtr lk; |
|
|
if (l == NULL) |
if (l == NULL) |
return(NULL); |
return(NULL); |
for(lk = l->sentinel->next;lk != l->sentinel && l->linkCompare(lk->data, data) <0 ;lk = lk->next); |
for(lk = l->sentinel->next;lk != l->sentinel && l->linkCompare(lk->data, data) <0 ;lk = lk->next); |
return lk; | return lk; |
} |
} |
|
|
/** |
/** |
Line 114 xmlListLowerSearch(xmlListPtr l, void *data)
|
Line 114 xmlListLowerSearch(xmlListPtr l, void *data)
|
* |
* |
* Returns the link containing the data or NULL |
* Returns the link containing the data or NULL |
*/ |
*/ |
static xmlLinkPtr | static xmlLinkPtr |
xmlListHigherSearch(xmlListPtr l, void *data) | xmlListHigherSearch(xmlListPtr l, void *data) |
{ |
{ |
xmlLinkPtr lk; |
xmlLinkPtr lk; |
|
|
if (l == NULL) |
if (l == NULL) |
return(NULL); |
return(NULL); |
for(lk = l->sentinel->prev;lk != l->sentinel && l->linkCompare(lk->data, data) >0 ;lk = lk->prev); |
for(lk = l->sentinel->prev;lk != l->sentinel && l->linkCompare(lk->data, data) >0 ;lk = lk->prev); |
return lk; | return lk; |
} |
} |
|
|
/** |
/** |
Line 134 xmlListHigherSearch(xmlListPtr l, void *data)
|
Line 134 xmlListHigherSearch(xmlListPtr l, void *data)
|
* |
* |
* Returns the link containing the data or NULL |
* Returns the link containing the data or NULL |
*/ |
*/ |
static xmlLinkPtr | static xmlLinkPtr |
xmlListLinkSearch(xmlListPtr l, void *data) | xmlListLinkSearch(xmlListPtr l, void *data) |
{ |
{ |
xmlLinkPtr lk; |
xmlLinkPtr lk; |
if (l == NULL) |
if (l == NULL) |
Line 159 xmlListLinkSearch(xmlListPtr l, void *data)
|
Line 159 xmlListLinkSearch(xmlListPtr l, void *data)
|
* |
* |
* Returns the link containing the data or NULL |
* Returns the link containing the data or NULL |
*/ |
*/ |
static xmlLinkPtr | static xmlLinkPtr |
xmlListLinkReverseSearch(xmlListPtr l, void *data) | xmlListLinkReverseSearch(xmlListPtr l, void *data) |
{ |
{ |
xmlLinkPtr lk; |
xmlLinkPtr lk; |
if (l == NULL) |
if (l == NULL) |
Line 189 xmlListCreate(xmlListDeallocator deallocator, xmlListD
|
Line 189 xmlListCreate(xmlListDeallocator deallocator, xmlListD
|
{ |
{ |
xmlListPtr l; |
xmlListPtr l; |
if (NULL == (l = (xmlListPtr )xmlMalloc( sizeof(xmlList)))) { |
if (NULL == (l = (xmlListPtr )xmlMalloc( sizeof(xmlList)))) { |
xmlGenericError(xmlGenericErrorContext, | xmlGenericError(xmlGenericErrorContext, |
"Cannot initialize memory for list"); |
"Cannot initialize memory for list"); |
return (NULL); |
return (NULL); |
} |
} |
/* Initialize the list to NULL */ |
/* Initialize the list to NULL */ |
memset(l, 0, sizeof(xmlList)); |
memset(l, 0, sizeof(xmlList)); |
| |
/* Add the sentinel */ |
/* Add the sentinel */ |
if (NULL ==(l->sentinel = (xmlLinkPtr )xmlMalloc(sizeof(xmlLink)))) { |
if (NULL ==(l->sentinel = (xmlLinkPtr )xmlMalloc(sizeof(xmlLink)))) { |
xmlGenericError(xmlGenericErrorContext, | xmlGenericError(xmlGenericErrorContext, |
"Cannot initialize memory for sentinel"); |
"Cannot initialize memory for sentinel"); |
xmlFree(l); |
xmlFree(l); |
return (NULL); |
return (NULL); |
Line 206 xmlListCreate(xmlListDeallocator deallocator, xmlListD
|
Line 206 xmlListCreate(xmlListDeallocator deallocator, xmlListD
|
l->sentinel->next = l->sentinel; |
l->sentinel->next = l->sentinel; |
l->sentinel->prev = l->sentinel; |
l->sentinel->prev = l->sentinel; |
l->sentinel->data = NULL; |
l->sentinel->data = NULL; |
| |
/* If there is a link deallocator, use it */ |
/* If there is a link deallocator, use it */ |
if (deallocator != NULL) |
if (deallocator != NULL) |
l->linkDeallocator = deallocator; |
l->linkDeallocator = deallocator; |
Line 217 xmlListCreate(xmlListDeallocator deallocator, xmlListD
|
Line 217 xmlListCreate(xmlListDeallocator deallocator, xmlListD
|
l->linkCompare = xmlLinkCompare; |
l->linkCompare = xmlLinkCompare; |
return l; |
return l; |
} |
} |
| |
/** |
/** |
* xmlListSearch: |
* xmlListSearch: |
* @l: a list |
* @l: a list |
Line 228 xmlListCreate(xmlListDeallocator deallocator, xmlListD
|
Line 228 xmlListCreate(xmlListDeallocator deallocator, xmlListD
|
* Returns the value associated to @data or NULL in case of error |
* Returns the value associated to @data or NULL in case of error |
*/ |
*/ |
void * |
void * |
xmlListSearch(xmlListPtr l, void *data) | xmlListSearch(xmlListPtr l, void *data) |
{ |
{ |
xmlLinkPtr lk; |
xmlLinkPtr lk; |
if (l == NULL) |
if (l == NULL) |
Line 249 xmlListSearch(xmlListPtr l, void *data)
|
Line 249 xmlListSearch(xmlListPtr l, void *data)
|
* Returns the value associated to @data or NULL in case of error |
* Returns the value associated to @data or NULL in case of error |
*/ |
*/ |
void * |
void * |
xmlListReverseSearch(xmlListPtr l, void *data) | xmlListReverseSearch(xmlListPtr l, void *data) |
{ |
{ |
xmlLinkPtr lk; |
xmlLinkPtr lk; |
if (l == NULL) |
if (l == NULL) |
Line 270 xmlListReverseSearch(xmlListPtr l, void *data)
|
Line 270 xmlListReverseSearch(xmlListPtr l, void *data)
|
* Returns 0 in case of success, 1 in case of failure |
* Returns 0 in case of success, 1 in case of failure |
*/ |
*/ |
int |
int |
xmlListInsert(xmlListPtr l, void *data) | xmlListInsert(xmlListPtr l, void *data) |
{ |
{ |
xmlLinkPtr lkPlace, lkNew; |
xmlLinkPtr lkPlace, lkNew; |
|
|
Line 280 xmlListInsert(xmlListPtr l, void *data)
|
Line 280 xmlListInsert(xmlListPtr l, void *data)
|
/* Add the new link */ |
/* Add the new link */ |
lkNew = (xmlLinkPtr) xmlMalloc(sizeof(xmlLink)); |
lkNew = (xmlLinkPtr) xmlMalloc(sizeof(xmlLink)); |
if (lkNew == NULL) { |
if (lkNew == NULL) { |
xmlGenericError(xmlGenericErrorContext, | xmlGenericError(xmlGenericErrorContext, |
"Cannot initialize memory for new link"); |
"Cannot initialize memory for new link"); |
return (1); |
return (1); |
} |
} |
Line 302 xmlListInsert(xmlListPtr l, void *data)
|
Line 302 xmlListInsert(xmlListPtr l, void *data)
|
* |
* |
* Returns 0 in case of success, 1 in case of failure |
* Returns 0 in case of success, 1 in case of failure |
*/ |
*/ |
int xmlListAppend(xmlListPtr l, void *data) | int xmlListAppend(xmlListPtr l, void *data) |
{ |
{ |
xmlLinkPtr lkPlace, lkNew; |
xmlLinkPtr lkPlace, lkNew; |
|
|
Line 312 int xmlListAppend(xmlListPtr l, void *data)
|
Line 312 int xmlListAppend(xmlListPtr l, void *data)
|
/* Add the new link */ |
/* Add the new link */ |
lkNew = (xmlLinkPtr) xmlMalloc(sizeof(xmlLink)); |
lkNew = (xmlLinkPtr) xmlMalloc(sizeof(xmlLink)); |
if (lkNew == NULL) { |
if (lkNew == NULL) { |
xmlGenericError(xmlGenericErrorContext, | xmlGenericError(xmlGenericErrorContext, |
"Cannot initialize memory for new link"); |
"Cannot initialize memory for new link"); |
return (1); |
return (1); |
} |
} |
Line 353 int
|
Line 353 int
|
xmlListRemoveFirst(xmlListPtr l, void *data) |
xmlListRemoveFirst(xmlListPtr l, void *data) |
{ |
{ |
xmlLinkPtr lk; |
xmlLinkPtr lk; |
| |
if (l == NULL) |
if (l == NULL) |
return(0); |
return(0); |
/*Find the first instance of this data */ |
/*Find the first instance of this data */ |
Line 378 int
|
Line 378 int
|
xmlListRemoveLast(xmlListPtr l, void *data) |
xmlListRemoveLast(xmlListPtr l, void *data) |
{ |
{ |
xmlLinkPtr lk; |
xmlLinkPtr lk; |
| |
if (l == NULL) |
if (l == NULL) |
return(0); |
return(0); |
/*Find the last instance of this data */ |
/*Find the last instance of this data */ |
Line 403 int
|
Line 403 int
|
xmlListRemoveAll(xmlListPtr l, void *data) |
xmlListRemoveAll(xmlListPtr l, void *data) |
{ |
{ |
int count=0; |
int count=0; |
| |
if (l == NULL) |
if (l == NULL) |
return(0); |
return(0); |
|
|
Line 422 void
|
Line 422 void
|
xmlListClear(xmlListPtr l) |
xmlListClear(xmlListPtr l) |
{ |
{ |
xmlLinkPtr lk; |
xmlLinkPtr lk; |
| |
if (l == NULL) |
if (l == NULL) |
return; |
return; |
lk = l->sentinel->next; |
lk = l->sentinel->next; |
Line 458 xmlListEmpty(xmlListPtr l)
|
Line 458 xmlListEmpty(xmlListPtr l)
|
* |
* |
* Returns the first element in the list, or NULL |
* Returns the first element in the list, or NULL |
*/ |
*/ |
xmlLinkPtr | xmlLinkPtr |
xmlListFront(xmlListPtr l) |
xmlListFront(xmlListPtr l) |
{ |
{ |
if (l == NULL) |
if (l == NULL) |
return(NULL); |
return(NULL); |
return (l->sentinel->next); |
return (l->sentinel->next); |
} |
} |
| |
/** |
/** |
* xmlListEnd: |
* xmlListEnd: |
* @l: a list |
* @l: a list |
Line 474 xmlListFront(xmlListPtr l)
|
Line 474 xmlListFront(xmlListPtr l)
|
* |
* |
* Returns the last element in the list, or NULL |
* Returns the last element in the list, or NULL |
*/ |
*/ |
xmlLinkPtr | xmlLinkPtr |
xmlListEnd(xmlListPtr l) |
xmlListEnd(xmlListPtr l) |
{ |
{ |
if (l == NULL) |
if (l == NULL) |
return(NULL); |
return(NULL); |
return (l->sentinel->prev); |
return (l->sentinel->prev); |
} |
} |
| |
/** |
/** |
* xmlListSize: |
* xmlListSize: |
* @l: a list |
* @l: a list |
Line 539 xmlListPopBack(xmlListPtr l)
|
Line 539 xmlListPopBack(xmlListPtr l)
|
* Returns 1 if successful, 0 otherwise |
* Returns 1 if successful, 0 otherwise |
*/ |
*/ |
int |
int |
xmlListPushFront(xmlListPtr l, void *data) | xmlListPushFront(xmlListPtr l, void *data) |
{ |
{ |
xmlLinkPtr lkPlace, lkNew; |
xmlLinkPtr lkPlace, lkNew; |
|
|
Line 549 xmlListPushFront(xmlListPtr l, void *data)
|
Line 549 xmlListPushFront(xmlListPtr l, void *data)
|
/* Add the new link */ |
/* Add the new link */ |
lkNew = (xmlLinkPtr) xmlMalloc(sizeof(xmlLink)); |
lkNew = (xmlLinkPtr) xmlMalloc(sizeof(xmlLink)); |
if (lkNew == NULL) { |
if (lkNew == NULL) { |
xmlGenericError(xmlGenericErrorContext, | xmlGenericError(xmlGenericErrorContext, |
"Cannot initialize memory for new link"); |
"Cannot initialize memory for new link"); |
return (0); |
return (0); |
} |
} |
Line 571 xmlListPushFront(xmlListPtr l, void *data)
|
Line 571 xmlListPushFront(xmlListPtr l, void *data)
|
* Returns 1 if successful, 0 otherwise |
* Returns 1 if successful, 0 otherwise |
*/ |
*/ |
int |
int |
xmlListPushBack(xmlListPtr l, void *data) | xmlListPushBack(xmlListPtr l, void *data) |
{ |
{ |
xmlLinkPtr lkPlace, lkNew; |
xmlLinkPtr lkPlace, lkNew; |
|
|
Line 580 xmlListPushBack(xmlListPtr l, void *data)
|
Line 580 xmlListPushBack(xmlListPtr l, void *data)
|
lkPlace = l->sentinel->prev; |
lkPlace = l->sentinel->prev; |
/* Add the new link */ |
/* Add the new link */ |
if (NULL ==(lkNew = (xmlLinkPtr )xmlMalloc(sizeof(xmlLink)))) { |
if (NULL ==(lkNew = (xmlLinkPtr )xmlMalloc(sizeof(xmlLink)))) { |
xmlGenericError(xmlGenericErrorContext, | xmlGenericError(xmlGenericErrorContext, |
"Cannot initialize memory for new link"); |
"Cannot initialize memory for new link"); |
return (0); |
return (0); |
} |
} |
Line 643 void
|
Line 643 void
|
xmlListSort(xmlListPtr l) |
xmlListSort(xmlListPtr l) |
{ |
{ |
xmlListPtr lTemp; |
xmlListPtr lTemp; |
| |
if (l == NULL) |
if (l == NULL) |
return; |
return; |
if(xmlListEmpty(l)) |
if(xmlListEmpty(l)) |
Line 725 xmlListMerge(xmlListPtr l1, xmlListPtr l2)
|
Line 725 xmlListMerge(xmlListPtr l1, xmlListPtr l2)
|
* @old: the list |
* @old: the list |
* |
* |
* Duplicate the list |
* Duplicate the list |
* | * |
* Returns a new copy of the list or NULL in case of error |
* Returns a new copy of the list or NULL in case of error |
*/ |
*/ |
xmlListPtr | xmlListPtr |
xmlListDup(const xmlListPtr old) |
xmlListDup(const xmlListPtr old) |
{ |
{ |
xmlListPtr cur; |
xmlListPtr cur; |
Line 754 xmlListDup(const xmlListPtr old)
|
Line 754 xmlListDup(const xmlListPtr old)
|
* @old: the old list |
* @old: the old list |
* |
* |
* Move all the element from the old list in the new list |
* Move all the element from the old list in the new list |
* | * |
* Returns 0 in case of success 1 in case of error |
* Returns 0 in case of success 1 in case of error |
*/ |
*/ |
int |
int |
Line 771 xmlListCopy(xmlListPtr cur, const xmlListPtr old)
|
Line 771 xmlListCopy(xmlListPtr cur, const xmlListPtr old)
|
return (1); |
return (1); |
} |
} |
} |
} |
return (0); | return (0); |
} |
} |
/* xmlListUnique() */ |
/* xmlListUnique() */ |
/* xmlListSwap */ |
/* xmlListSwap */ |