Blame doc/devhelp/libxml2-xmlmemory.html

Packit 423ecb
Packit 423ecb
<html>
Packit 423ecb
  <head>
Packit 423ecb
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
Packit 423ecb
    <title>xmlmemory: interface for the memory allocator</title>
Packit 423ecb
    <meta name="generator" content="Libxml2 devhelp stylesheet"/>
Packit 423ecb
    <link rel="start" href="index.html" title="libxml2 Reference Manual"/>
Packit 423ecb
    <link rel="up" href="general.html" title="API"/>
Packit 423ecb
    <link rel="stylesheet" href="style.css" type="text/css"/>
Packit 423ecb
    <link rel="chapter" href="general.html" title="API"/>
Packit 423ecb
  </head>
Packit 423ecb
  <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
Packit 423ecb
    
Packit 423ecb
      
Packit 423ecb
        
Packit 423ecb
          
Packit 423ecb
            Prev
Packit 423ecb
          
Packit 423ecb
        
Packit 423ecb
        
Packit 423ecb
          
Packit 423ecb
            Up
Packit 423ecb
          
Packit 423ecb
        
Packit 423ecb
        
Packit 423ecb
          
Packit 423ecb
            Home
Packit 423ecb
          
Packit 423ecb
        
Packit 423ecb
        
Packit 423ecb
          
Packit 423ecb
            Next
Packit 423ecb
          
Packit 423ecb
        
Packit 423ecb
        libxml2 Reference Manual
Packit 423ecb
      
Packit 423ecb
    
Packit 423ecb
    

Packit 423ecb
      xmlmemory
Packit 423ecb
    
Packit 423ecb
    

xmlmemory - interface for the memory allocator

Packit 423ecb
    

provides interfaces for the memory allocator, including debugging capabilities.

Packit 423ecb
    

Author(s): Daniel Veillard

Packit 423ecb
    
Packit 423ecb
      

Synopsis

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

Description

Packit 423ecb
    
Packit 423ecb
    
Packit 423ecb
      

Details

Packit 423ecb
      
Packit 423ecb
        

Macro DEBUG_MEMORY

#define DEBUG_MEMORY;
Packit 423ecb

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
Packit 423ecb
        
Packit 423ecb
        
Packit 423ecb

Signature for a free() implementation.

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

Signature for a malloc() implementation.

Packit 423ecb
<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
        
Packit 423ecb
        
Packit 423ecb

Signature for a realloc() implementation.

Packit 423ecb
<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
        
Packit 423ecb
        
Packit 423ecb

Signature for an strdup() implementation.

Packit 423ecb
<tt>str</tt>:a zero terminated string
<tt>Returns</tt>:the copy of the string or NULL in case of error.
Packit 423ecb
        
Packit 423ecb
        
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
Packit 423ecb
        
Packit 423ecb
        

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
Packit 423ecb
        
Packit 423ecb
        

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
Packit 423ecb
        
Packit 423ecb
        
Packit 423ecb

Initialize the memory layer.

Packit 423ecb
<tt>Returns</tt>:0 on success
Packit 423ecb
        
Packit 423ecb
        
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.
Packit 423ecb
        
Packit 423ecb
        
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.
Packit 423ecb
        
Packit 423ecb
        
Packit 423ecb

Provides the number of memory areas currently allocated

Packit 423ecb
<tt>Returns</tt>:an int representing the number of blocks
Packit 423ecb
        
Packit 423ecb
        
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
Packit 423ecb
        
Packit 423ecb
        
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
Packit 423ecb
        
Packit 423ecb
        
Packit 423ecb

a free() equivalent, with error checking.

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

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
Packit 423ecb
        
Packit 423ecb
        
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.
Packit 423ecb
        
Packit 423ecb
        
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.
Packit 423ecb
        
Packit 423ecb
        
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
Packit 423ecb
        
Packit 423ecb
        
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
Packit 423ecb
        
Packit 423ecb
        
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.
Packit 423ecb
        
Packit 423ecb
        
Packit 423ecb

Provides the amount of memory currently allocated

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

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

Packit 423ecb
Packit 423ecb
        
Packit 423ecb
        
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.
Packit 423ecb
        
Packit 423ecb
        
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.
Packit 423ecb
        
Packit 423ecb
      
Packit 423ecb
    
Packit 423ecb
  </body>
Packit 423ecb
</html>