Blame doc/html/libxml-xmlmemory.html

Packit 423ecb
Packit 423ecb
Packit 423ecb
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><link rel="SHORTCUT ICON" href="/favicon.ico" /><style type="text/css">
Packit 423ecb
TD {font-family: Verdana,Arial,Helvetica}
Packit 423ecb
BODY {font-family: Verdana,Arial,Helvetica; margin-top: 2em; margin-left: 0em; margin-right: 0em}
Packit 423ecb
H1 {font-family: Verdana,Arial,Helvetica}
Packit 423ecb
H2 {font-family: Verdana,Arial,Helvetica}
Packit 423ecb
H3 {font-family: Verdana,Arial,Helvetica}
Packit 423ecb
A:link, A:visited, A:active { text-decoration: underline }
Packit 423ecb
</style><style type="text/css">
Packit 423ecb
      div.deprecated pre.programlisting {border-style: double;border-color:red}
Packit 423ecb
      pre.programlisting {border-style: double;background: #EECFA1}
Packit 423ecb
    </style><title>Module xmlmemory from libxml2</title></head><body bgcolor="#8b7765" text="#000000" link="#a06060" vlink="#000000">
Action against software patentsGnome2 LogoW3C LogoRed Hat Logo
Made with Libxml2 Logo

Module xmlmemory from libxml2

<center>API Menu</center>
<form action="../search.php" enctype="application/x-www-form-urlencoded" method="get"><input name="query" type="text" size="20" value="" /><input name="submit" type="submit" value="Search ..." /></form>
<center>API Indexes</center>
<center>Related links</center>

provides interfaces for the memory allocator, including debugging capabilities.

Table of Contents

#define DEBUG_MEMORY
Variable xmlMallocFunc xmlMalloc
Packit 423ecb
Packit 423ecb
Variable xmlMallocFunc xmlMallocAtomic
Packit 423ecb
Packit 423ecb
Variable xmlStrdupFunc xmlMemStrdup
Packit 423ecb
Packit 423ecb
Variable xmlReallocFunc xmlRealloc
Packit 423ecb
Packit 423ecb
void	xmlCleanupMemory		(void)
Packit 423ecb
Function type: xmlFreeFunc
Packit 423ecb
void	xmlFreeFunc			(void * mem)
Packit 423ecb
Packit 423ecb
int	xmlGcMemGet			(xmlFreeFunc * freeFunc, 
xmlMallocFunc * mallocFunc,
xmlMallocFunc * mallocAtomicFunc,
xmlReallocFunc * reallocFunc,
xmlStrdupFunc * strdupFunc)
Packit 423ecb
int	xmlGcMemSetup			(xmlFreeFunc freeFunc, 
xmlMallocFunc mallocFunc,
xmlMallocFunc mallocAtomicFunc,
xmlReallocFunc reallocFunc,
xmlStrdupFunc strdupFunc)
Packit 423ecb
int	xmlInitMemory			(void)
Packit 423ecb
void *	xmlMallocAtomicLoc		(size_t size, 
const char * file,
int line)
Packit 423ecb
Function type: xmlMallocFunc
Packit 423ecb
void *	xmlMallocFunc			(size_t size)
Packit 423ecb
Packit 423ecb
void *	xmlMallocLoc			(size_t size, 
const char * file,
int line)
Packit 423ecb
int	xmlMemBlocks			(void)
Packit 423ecb
void	xmlMemDisplay			(FILE * fp)
Packit 423ecb
void	xmlMemDisplayLast		(FILE * fp, 
long nbBytes)
Packit 423ecb
void	xmlMemFree			(void * ptr)
Packit 423ecb
int	xmlMemGet			(xmlFreeFunc * freeFunc, 
xmlMallocFunc * mallocFunc,
xmlReallocFunc * reallocFunc,
xmlStrdupFunc * strdupFunc)
Packit 423ecb
void *	xmlMemMalloc			(size_t size)
Packit 423ecb
void *	xmlMemRealloc			(void * ptr, 
size_t size)
Packit 423ecb
int	xmlMemSetup			(xmlFreeFunc freeFunc, 
xmlMallocFunc mallocFunc,
xmlReallocFunc reallocFunc,
xmlStrdupFunc strdupFunc)
Packit 423ecb
void	xmlMemShow			(FILE * fp, 
int nr)
Packit 423ecb
char *	xmlMemStrdupLoc			(const char * str, 
const char * file,
int line)
Packit 423ecb
int	xmlMemUsed			(void)
Packit 423ecb
void	xmlMemoryDump			(void)
Packit 423ecb
char *	xmlMemoryStrdup			(const char * str)
Packit 423ecb
Function type: xmlReallocFunc
Packit 423ecb
void *	xmlReallocFunc			(void * mem, 
size_t size)
Packit 423ecb
Packit 423ecb
void *	xmlReallocLoc			(void * ptr, 
size_t size,
const char * file,
int line)
Packit 423ecb
Function type: xmlStrdupFunc
Packit 423ecb
char *	xmlStrdupFunc			(const char * str)
Packit 423ecb
Packit 423ecb

Description

Packit 423ecb

Macro: DEBUG_MEMORY

#define DEBUG_MEMORY

DEBUG_MEMORY replaces the allocator with a collect and debug shell to the libc allocator. DEBUG_MEMORY should only be activated when debugging libxml i.e. if libxml has been configured with --with-debug-mem too. #define DEBUG_MEMORY_FREED #define DEBUG_MEMORY_LOCATION

Packit 423ecb

Function: xmlCleanupMemory

void	xmlCleanupMemory		(void)
Packit 423ecb

Free up all the memory allocated by the library for its own use. This should not be called by user level code.

Packit 423ecb

Function type: xmlFreeFunc

Function type: xmlFreeFunc
Packit 423ecb
void	xmlFreeFunc			(void * mem)
Packit 423ecb

Signature for a free() implementation.

<tt>mem</tt>:an already allocated block of memory

Packit 423ecb

Function: xmlGcMemGet

int	xmlGcMemGet			(xmlFreeFunc * freeFunc, 
xmlMallocFunc * mallocFunc,
xmlMallocFunc * mallocAtomicFunc,
xmlReallocFunc * reallocFunc,
xmlStrdupFunc * strdupFunc)
Packit 423ecb

Provides the memory access functions set currently in use The mallocAtomicFunc is specialized for atomic block allocations (i.e. of areas useful for garbage collected memory allocators

Packit 423ecb
<tt>freeFunc</tt>:place to save the free() function in use
<tt>mallocFunc</tt>:place to save the malloc() function in use
<tt>mallocAtomicFunc</tt>:place to save the atomic malloc() function in use
<tt>reallocFunc</tt>:place to save the realloc() function in use
<tt>strdupFunc</tt>:place to save the strdup() function in use
<tt>Returns</tt>:0 on success

Function: xmlGcMemSetup

int	xmlGcMemSetup			(xmlFreeFunc freeFunc, 
xmlMallocFunc mallocFunc,
xmlMallocFunc mallocAtomicFunc,
xmlReallocFunc reallocFunc,
xmlStrdupFunc strdupFunc)
Packit 423ecb

Override the default memory access functions with a new set This has to be called before any other libxml routines ! The mallocAtomicFunc is specialized for atomic block allocations (i.e. of areas useful for garbage collected memory allocators Should this be blocked if there was already some allocations done ?

Packit 423ecb
<tt>freeFunc</tt>:the free() function to use
<tt>mallocFunc</tt>:the malloc() function to use
<tt>mallocAtomicFunc</tt>:the malloc() function to use for atomic allocations
<tt>reallocFunc</tt>:the realloc() function to use
<tt>strdupFunc</tt>:the strdup() function to use
<tt>Returns</tt>:0 on success

Function: xmlInitMemory

int	xmlInitMemory			(void)
Packit 423ecb

Initialize the memory layer.

Packit 423ecb
<tt>Returns</tt>:0 on success

Function: xmlMallocAtomicLoc

void *	xmlMallocAtomicLoc		(size_t size, 
const char * file,
int line)
Packit 423ecb

a malloc() equivalent, with logging of the allocation info.

Packit 423ecb
<tt>size</tt>:an unsigned int specifying the size in byte to allocate.
<tt>file</tt>:the file name or NULL
<tt>line</tt>:the line number
<tt>Returns</tt>:a pointer to the allocated area or NULL in case of lack of memory.

Function type: xmlMallocFunc

Function type: xmlMallocFunc
Packit 423ecb
void *	xmlMallocFunc			(size_t size)
Packit 423ecb

Signature for a malloc() implementation.

<tt>size</tt>:the size requested in bytes
<tt>Returns</tt>:a pointer to the newly allocated block or NULL in case of error.

Packit 423ecb

Function: xmlMallocLoc

void *	xmlMallocLoc			(size_t size, 
const char * file,
int line)
Packit 423ecb

a malloc() equivalent, with logging of the allocation info.

Packit 423ecb
<tt>size</tt>:an int specifying the size in byte to allocate.
<tt>file</tt>:the file name or NULL
<tt>line</tt>:the line number
<tt>Returns</tt>:a pointer to the allocated area or NULL in case of lack of memory.

Function: xmlMemBlocks

int	xmlMemBlocks			(void)
Packit 423ecb

Provides the number of memory areas currently allocated

Packit 423ecb
<tt>Returns</tt>:an int representing the number of blocks

Function: xmlMemDisplay

void	xmlMemDisplay			(FILE * fp)
Packit 423ecb

show in-extenso the memory blocks allocated

Packit 423ecb
<tt>fp</tt>:a FILE descriptor used as the output file, if NULL, the result is written to the file .memorylist

Function: xmlMemDisplayLast

void	xmlMemDisplayLast		(FILE * fp, 
long nbBytes)
Packit 423ecb

the last nbBytes of memory allocated and not freed, useful for dumping the memory left allocated between two places at runtime.

Packit 423ecb
<tt>fp</tt>:a FILE descriptor used as the output file, if NULL, the result is written to the file .memorylist
<tt>nbBytes</tt>:the amount of memory to dump

Function: xmlMemFree

void	xmlMemFree			(void * ptr)
Packit 423ecb

a free() equivalent, with error checking.

Packit 423ecb
<tt>ptr</tt>:the memory block pointer

Function: xmlMemGet

int	xmlMemGet			(xmlFreeFunc * freeFunc, 
xmlMallocFunc * mallocFunc,
xmlReallocFunc * reallocFunc,
xmlStrdupFunc * strdupFunc)
Packit 423ecb

Provides the memory access functions set currently in use

Packit 423ecb
<tt>freeFunc</tt>:place to save the free() function in use
<tt>mallocFunc</tt>:place to save the malloc() function in use
<tt>reallocFunc</tt>:place to save the realloc() function in use
<tt>strdupFunc</tt>:place to save the strdup() function in use
<tt>Returns</tt>:0 on success

Function: xmlMemMalloc

void *	xmlMemMalloc			(size_t size)
Packit 423ecb

a malloc() equivalent, with logging of the allocation info.

Packit 423ecb
<tt>size</tt>:an int specifying the size in byte to allocate.
<tt>Returns</tt>:a pointer to the allocated area or NULL in case of lack of memory.

Function: xmlMemRealloc

void *	xmlMemRealloc			(void * ptr, 
size_t size)
Packit 423ecb

a realloc() equivalent, with logging of the allocation info.

Packit 423ecb
<tt>ptr</tt>:the initial memory block pointer
<tt>size</tt>:an int specifying the size in byte to allocate.
<tt>Returns</tt>:a pointer to the allocated area or NULL in case of lack of memory.

Function: xmlMemSetup

int	xmlMemSetup			(xmlFreeFunc freeFunc, 
xmlMallocFunc mallocFunc,
xmlReallocFunc reallocFunc,
xmlStrdupFunc strdupFunc)
Packit 423ecb

Override the default memory access functions with a new set This has to be called before any other libxml routines ! Should this be blocked if there was already some allocations done ?

Packit 423ecb
<tt>freeFunc</tt>:the free() function to use
<tt>mallocFunc</tt>:the malloc() function to use
<tt>reallocFunc</tt>:the realloc() function to use
<tt>strdupFunc</tt>:the strdup() function to use
<tt>Returns</tt>:0 on success

Function: xmlMemShow

void	xmlMemShow			(FILE * fp, 
int nr)
Packit 423ecb

show a show display of the memory allocated, and dump the @nr last allocated areas which were not freed

Packit 423ecb
<tt>fp</tt>:a FILE descriptor used as the output file
<tt>nr</tt>:number of entries to dump

Function: xmlMemStrdupLoc

char *	xmlMemStrdupLoc			(const char * str, 
const char * file,
int line)
Packit 423ecb

a strdup() equivalent, with logging of the allocation info.

Packit 423ecb
<tt>str</tt>:the initial string pointer
<tt>file</tt>:the file name or NULL
<tt>line</tt>:the line number
<tt>Returns</tt>:a pointer to the new string or NULL if allocation error occurred.

Function: xmlMemUsed

int	xmlMemUsed			(void)
Packit 423ecb

Provides the amount of memory currently allocated

Packit 423ecb
<tt>Returns</tt>:an int representing the amount of memory allocated.

Function: xmlMemoryDump

void	xmlMemoryDump			(void)
Packit 423ecb

Dump in-extenso the memory blocks allocated to the file .memorylist

Packit 423ecb

Function: xmlMemoryStrdup

char *	xmlMemoryStrdup			(const char * str)
Packit 423ecb

a strdup() equivalent, with logging of the allocation info.

Packit 423ecb
<tt>str</tt>:the initial string pointer
<tt>Returns</tt>:a pointer to the new string or NULL if allocation error occurred.

Function type: xmlReallocFunc

Function type: xmlReallocFunc
Packit 423ecb
void *	xmlReallocFunc			(void * mem, 
size_t size)
Packit 423ecb

Signature for a realloc() implementation.

<tt>mem</tt>:an already allocated block of memory
<tt>size</tt>:the new size requested in bytes
<tt>Returns</tt>:a pointer to the newly reallocated block or NULL in case of error.

Packit 423ecb

Function: xmlReallocLoc

void *	xmlReallocLoc			(void * ptr, 
size_t size,
const char * file,
int line)
Packit 423ecb

a realloc() equivalent, with logging of the allocation info.

Packit 423ecb
<tt>ptr</tt>:the initial memory block pointer
<tt>size</tt>:an int specifying the size in byte to allocate.
<tt>file</tt>:the file name or NULL
<tt>line</tt>:the line number
<tt>Returns</tt>:a pointer to the allocated area or NULL in case of lack of memory.

Function type: xmlStrdupFunc

Function type: xmlStrdupFunc
Packit 423ecb
char *	xmlStrdupFunc			(const char * str)
Packit 423ecb

Signature for an strdup() implementation.

<tt>str</tt>:a zero terminated string
<tt>Returns</tt>:the copy of the string or NULL in case of error.

Packit 423ecb

Daniel Veillard

</body></html>