Gnome XML Library Reference Manual
<<< Previous Page | Home | Up |

# xmlmemory

## Name

xmlmemory --

## Synopsis

    #define     DEBUG_MEMORY
    #define     MEM_LIST
    void        (*xmlFreeFunc)                  (void*);
    void*       (*xmlMallocFunc)                (...);
    void*       (*xmlReallocFunc)               (void*,
                                                 ...);
    char*       (*xmlStrdupFunc)                (const char*);
    int         xmlMemSetup                     (xmlFreeFunc freeFunc,
                                                 xmlMallocFunc mallocFunc,
                                                 xmlReallocFunc reallocFunc,
                                                 xmlStrdupFunc strdupFunc);
    int         xmlMemGet                       (xmlFreeFunc *freeFunc,
                                                 xmlMallocFunc *mallocFunc,
                                                 xmlReallocFunc *reallocFunc,
                                                 xmlStrdupFunc *strdupFunc);
    int         xmlInitMemory                   (void);
    int         xmlMemUsed                      (void);
    void        xmlMemDisplay                   (FILE *fp);
    void        xmlMemShow                      (FILE *fp,
                                                 int nr);
    void        xmlMemoryDump                   (void);
    #define     xmlMalloc                       (x)
    #define     xmlRealloc                      (p, x)
    #define     xmlMemStrdup                    (x)
    void*       xmlMallocLoc                    (int size,
                                                 const char *file,
                                                 int line);
    void*       xmlReallocLoc                   (void *ptr,
                                                 int size,
                                                 const char *file,
                                                 int line);
    char*       xmlMemStrdupLoc                 (const char *str,
                                                 const char *file,
                                                 int line);

## Description

## Details

### DEBUG_MEMORY

    #define DEBUG_MEMORY

### MEM_LIST

    #define MEM_LIST /* keep a list of all the allocated memory blocks */

### xmlFreeFunc ()

    void        (*xmlFreeFunc)                  (void*);

`Param1` : |

### xmlMallocFunc ()

    void*       (*xmlMallocFunc)                (...);

`...` : |

### xmlReallocFunc ()

    void*       (*xmlReallocFunc)               (void*,
                                                 ...);

`Param1` : |
`...` : |

### xmlStrdupFunc ()

    char*       (*xmlStrdupFunc)                (const char*);

`Param1` : |
Returns : |

### xmlMemSetup ()

    int         xmlMemSetup                     (xmlFreeFunc freeFunc,
                                                 xmlMallocFunc mallocFunc,
                                                 xmlReallocFunc reallocFunc,
                                                 xmlStrdupFunc strdupFunc);

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 ?

`freeFunc` : | the free() function to use
`mallocFunc` : | the malloc() function to use
`reallocFunc` : | the realloc() function to use
`strdupFunc` : | the strdup() function to use
Returns : | 0 on success

### xmlMemGet ()

    int         xmlMemGet                       (xmlFreeFunc *freeFunc,
                                                 xmlMallocFunc *mallocFunc,
                                                 xmlReallocFunc *reallocFunc,
                                                 xmlStrdupFunc *strdupFunc);

Return the memory access functions set currently in use

`freeFunc` : | the free() function in use
`mallocFunc` : | the malloc() function in use
`reallocFunc` : | the realloc() function in use
`strdupFunc` : | the strdup() function in use
Returns : | 0 on success

### xmlInitMemory ()

    int         xmlInitMemory                   (void);

Initialize the memory layer.

Returns : | 0 on success

### xmlMemUsed ()

    int         xmlMemUsed                      (void);

returns the amount of memory currenly allocated

Returns : | an int representing the amount of memory allocated.

### xmlMemDisplay ()

    void        xmlMemDisplay                   (FILE *fp);

show in-extenso the memory blocks allocated

`fp` : | a FILE descriptor used as the output file, if NULL, the result is written to the file .memorylist

### xmlMemShow ()

    void        xmlMemShow                      (FILE *fp,
                                                 int nr);

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

`fp` : | a FILE descriptor used as the output file
`nr` : | number of entries to dump

### xmlMemoryDump ()

    void        xmlMemoryDump                   (void);

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

### xmlMalloc()

    #define xmlMalloc(x) xmlMallocLoc((x), __FILE__, __LINE__)

`x` : |

### xmlRealloc()

    #define xmlRealloc(p, x) xmlReallocLoc((p), (x), __FILE__, __LINE__)

`p` : |
`x` : |

### xmlMemStrdup()

    #define xmlMemStrdup(x) xmlMemStrdupLoc((x), __FILE__, __LINE__)

`x` : |

### xmlMallocLoc ()

    void*       xmlMallocLoc                    (int size,
                                                 const char *file,
                                                 int line);

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

`size` : | an int specifying the size in byte to allocate.
`file` : | the file name or NULL
`line` : | the line number

### xmlReallocLoc ()

    void*       xmlReallocLoc                   (void *ptr,
                                                 int size,
                                                 const char *file,
                                                 int line);

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

`ptr` : | the initial memory block pointer
`size` : | an int specifying the size in byte to allocate.
`file` : | the file name or NULL
`line` : | the line number

### xmlMemStrdupLoc ()

    char*       xmlMemStrdupLoc                 (const char *str,
                                                 const char *file,
                                                 int line);

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

`str` : |
`file` : | the file name or NULL
`line` : | the line number
Returns : | a pointer to the new string or NULL if allocation error occured.

<<< Previous Page | Home | Up |
debugXML |