[xml] list deallocator problem
- From: Aleksey Sanin <aleksey aleksey com>
- To: xml gnome org
- Subject: [xml] list deallocator problem
- Date: Tue, 26 Feb 2002 12:34:44 -0800
Hi, All!
I am trying to use xmlList declared in list.h and I found a small
problem with it. The xmlListDeallocator is declared in list.h as follows:
typedef void (*xmlListDeallocator) (xmlLinkPtr lk);
i.e. it expects a pointer to xmlLink structure. However, the xmlLink structure
itself is declared inside list.c and by this it is not accessible to the
custom
list data deallocator. I would suggest to do following changes:
1) change the declaration of xmlListDeallocator in list.h to
typedef void (*xmlListDeallocator) (void *data);
2) change the implementation of xmlLinkDeallocator() in link.c
from
/**
* xmlLinkDeallocator:
* @l: a list
* @lk: a link
*
* Unlink and deallocate @lk from list @l
*/
static void
xmlLinkDeallocator(xmlListPtr l, xmlLinkPtr lk)
{
(lk->prev)->next = lk->next;
(lk->next)->prev = lk->prev;
if(l->linkDeallocator)
l->linkDeallocator(lk);
xmlFree(lk);
}
to
/**
* xmlLinkDeallocator:
* @l: a list
* @lk: a link
*
* Unlink and deallocate @lk from list @l
*/
static void
xmlLinkDeallocator(xmlListPtr l, xmlLinkPtr lk)
{
(lk->prev)->next = lk->next;
(lk->next)->prev = lk->prev;
if(l->linkDeallocator && lk->data)
l->linkDeallocator(lk->data);
xmlFree(lk);
}
Aleksey.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]