bugPanda PDF Generation API - Bugs: bug #10481, memory leaks

 
 

bug #10481: memory leaks

Submitted by:  None
Submitted on:  Thu 23 Sep 2004 03:07:52 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: None
Privacy: PublicAssigned to: None
Open/Closed: Open

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Thu 23 Sep 2004 03:07:52 PM UTC, original submission:

replace free malloc realloc by panda_xfree / panda_xrealloc /panda_xmalloc

windows_panda_abs *Tete=NULL;

void *
panda_xmalloc (size_t size)
{
void *buffer;
if ((buffer = malloc (size)) == NULL)
{
panda_error (panda_true, "panda_xmalloc failed to allocate memory");
}
else
{
windows_panda_ptrlist * NewPtr = (windows_panda_ptrlist *)malloc(sizeof(windows_panda_ptrlist));
if ( Tete == NULL )
{
Tete = (windows_panda_abs *)malloc(sizeof(windows_panda_abs));
Tete->list = NULL;
}
NewPtr->me = buffer;
NewPtr->next = Tete->list;
Tete->list = NewPtr;
}
return buffer;
}

void *
panda_xrealloc (void *memory, size_t size)
{
void *buffer;

if ( memory == NULL )
return panda_xmalloc(size);

if ((buffer = realloc (memory, size)) == NULL)
{
panda_error (panda_true, "panda_xrealloc failed to allocate memory");
}
else
{
if ( buffer != memory )
{
windows_panda_ptrlist * NewPtr = (windows_panda_ptrlist *)malloc(sizeof(windows_panda_ptrlist));

if ( Tete == NULL )
{
Tete = (windows_panda_abs *)malloc(sizeof(windows_panda_abs));
Tete->list = NULL;
}

if ((memory!=NULL)&&(Tete->list!=NULL))
{
windows_panda_ptrlist * PtrFinder;
windows_panda_ptrlist * PtrToDelete;

PtrFinder = Tete->list;
if ( memory == Tete->list->me )
{
PtrToDelete = Tete->list;
Tete->list = Tete->list->next;
free(PtrToDelete) ;
}
else
{
while ((PtrFinder->next!=NULL)&&(PtrFinder->next->me!=memory))
PtrFinder=PtrFinder->next;
if ( PtrFinder->next!=NULL )
{
PtrToDelete = PtrFinder->next;
PtrFinder->next = PtrFinder->next->next;
free(PtrToDelete) ;
}
}
}
NewPtr->me = buffer;
NewPtr->next = Tete->list;
Tete->list = NewPtr;
}
}
return buffer;
}

void panda_xfree(void *memory)
{
if ( Tete == NULL )
{
Tete = (windows_panda_abs *)malloc(sizeof(windows_panda_abs));
Tete->list = NULL;
}
if ((memory!=NULL)&&(Tete->list!=NULL))
{
windows_panda_ptrlist * PtrFinder;
windows_panda_ptrlist * PtrToDelete;

if ( memory == Tete->list->me )
{
PtrToDelete = Tete->list;
Tete->list = Tete->list->next;
free(PtrToDelete) ;
}
else
{
PtrFinder = Tete->list;
while ((PtrFinder->next!=NULL)&&(PtrFinder->next->me!=memory))
PtrFinder=PtrFinder->next;
if ( PtrFinder->next!=NULL )
{
PtrToDelete = PtrFinder->next;
PtrFinder->next = PtrFinder->next->next;
free(PtrToDelete) ;
}
}
}
free(memory);
}

void panda_xfreeAll()
{
windows_panda_ptrlist * PtrReader;
windows_panda_ptrlist * PtrVictim;

if (Tete!=NULL)
{
PtrReader = Tete->list;
free(Tete);
Tete = NULL;
while (PtrReader != NULL)
{
PtrVictim = PtrReader;
PtrReader = PtrReader->next;
free((void *)PtrVictim->me);
free(PtrVictim);
}
}
Tete = NULL;
}

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

Do you think this task is very important?
If so, you can click here to add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.

 

Please enter the title of George Orwell's famous dystopian book (it's a date):

 

 

No Changes Have Been Made to This Item

Back to the top


Powered by Savane 3.1-cleanup