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:  None Severity:  3 - Normal
Item Group:  None Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open

Add a New Comment (Rich 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 Files:
   
   
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 add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.

 

 

 

No changes have been made to this item

Back to the top


Powered by Savane 3.5