Main Page   File List   Globals  

leakbug.h File Reference

Leakbug. More...

#include <string.h>
#include <stdlib.h>

Go to the source code of this file.

Leakbug Debug Levels

#define LEAKBUG_SILENT   0
 Run leakbug silently.

#define LEAKBUG_WARNINGS   1
 Run leakbug with warnings outputted.

#define LEAKBUG_ERRORS   2
 Run leakbug with errors outputted.


Functions

void * lbMalloc (size_t size, const char *filename, int line, int debug_level)
 Allocates memory.

void * lbCalloc (size_t nmemb, size_t size, const char *filename, int line, int debug_level)
 Allocates and clears an array.

void * lbRealloc (void *data, size_t size, const char *filename, int line, int debug_level)
 Reallocates memory.

void lbFree (void *ptr, const char *filename, int line, int debug_level)
 Frees memory.

void * lbRegister (void *ptr, unsigned int dataSize, const char *filename, int line, int debug_level)
 Registers memory for leakbug to keep track of.

void ** lbRegisterArray (void **ptr, unsigned int dataSize, unsigned int numElements, const char *filename, int line, int debug_level)
 Registers memory in an array for leakbug to keep track of.

void lbFreeLeaks (void)
 Frees all known leaked memory.

void lbDumpLeaks (void)
 Displays a list of all known leaked memory.


Detailed Description

Leakbug.

Id:
leakbug.h,v 1.11 2002/05/21 22:01:10 chipx86 Exp
Copyright:
(C) 2001-2002 The GNUpdate Project. All rights reserved.
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details.

You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.


Function Documentation

void* lbCalloc size_t    nmemb,
size_t    size,
const char *    filename,
int    line,
int    debug_level
 

Allocates and clears an array.

This wraps around calloc().

Parameters:
nmemb  The number of elements to allocate.
size  The size of each element.
filename  The calling filename.
line  The calling line number.
debug_level  The debug level.
Returns:
A pointer to the first element in the new chunk of memory.

void lbFree void *    ptr,
const char *    filename,
int    line,
int    debug_level
 

Frees memory.

This wraps around free().

Parameters:
ptr  The pointer to free.
filename  The calling filename.
line  The calling line number.
debug_level  The debug level.

void lbFreeLeaks void   
 

Frees all known leaked memory.

This is the easy way out of freeing memory, but it can be dangerous. You probably shouldn't use it.

void* lbMalloc size_t    size,
const char *    filename,
int    line,
int    debug_level
 

Allocates memory.

This wraps around malloc().

Parameters:
size  The size of the memory to allocate.
filename  The calling filename.
line  The calling line number.
debug_level  The debug level.
Returns:
A pointer to the new chunk of memory.

void* lbRealloc void *    data,
size_t    size,
const char *    filename,
int    line,
int    debug_level
 

Reallocates memory.

This wraps around realloc().

Parameters:
data  The data to reallocate.
size  The new size of the data.
filename  The calling filename.
line  The calling line number.
debug_level  The debug level.
Returns:
A pointer to the start of data.

void* lbRegister void *    ptr,
unsigned int    dataSize,
const char *    filename,
int    line,
int    debug_level
 

Registers memory for leakbug to keep track of.

This is used to register any memory not automatically handled by leakbug. This is useful when leakbug dumps "Freeing unknown memory" warnings in your program.

The easiest way to use this is to define macros in your program. For example:

 #ifdef WITH_LEAKBUG
  #include <leakbug.h>

  #define LB_REGISTER(ptr, dataSize) \
    lbRegister((ptr), (dataSize), __FILE__, __LINE__, LEAKBUG_DEBUG_LEVEL)
 #else
  #define LB_REGISTER(ptr, dataSize)
 #endif
Parameters:
ptr  The pointer to register.
dataSize  The size of the data.
filename  The calling filename.
line  The calling line number.
debug_level  The debug level.
Returns:
The pointer passed.
See also:
lbRegisterArray()

void** lbRegisterArray void **    ptr,
unsigned int    dataSize,
unsigned int    numElements,
const char *    filename,
int    line,
int    debug_level
 

Registers memory in an array for leakbug to keep track of.

This is used to register any memory not automatically handled by leakbug. This is useful when leakbug dumps "Freeing unknown memory" warnings in your program.

The easiest way to use this is to define macros in your program. For example:

 #ifdef WITH_LEAKBUG
  #include <leakbug.h>

  #define LB_REGISTER_ARRAY(ptr, dataSize, numElements) \
    lbRegisterArray((ptr), (dataSize), (numElements) \
                    __FILE__, __LINE__, LEAKBUG_DEBUG_LEVEL)
 #else
  #define LB_REGISTER_ARRAY(ptr, dataSize, numElements)
 #endif
Parameters:
ptr  The array pointer to register.
dataSize  The size of the data.
numElements  The number of elements in the array.
filename  The calling filename.
line  The calling line number.
debug_level  The debug level.
Returns:
The array pointer passed.
See also:
lbRegister()


Generated on Mon Jul 1 21:01:00 2002 for leakbug by doxygen1.2.15-20020430