epoc32/include/stdapis/libxml2/libxml2_xmlmemory.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
williamr@4
     1
/*
williamr@4
     2
 * Summary: interface for the memory allocator
williamr@4
     3
 * Description: provides interfaces for the memory allocator,
williamr@4
     4
 *              including debugging capabilities.
williamr@4
     5
 *
williamr@4
     6
 * Copy: See Copyright for the status of this software.
williamr@4
     7
 *
williamr@4
     8
 * Author: Daniel Veillard
williamr@4
     9
 * Portion Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. 
williamr@4
    10
 */
williamr@4
    11
williamr@4
    12
/** @file
williamr@4
    13
@publishedAll
williamr@4
    14
@released
williamr@4
    15
*/
williamr@4
    16
williamr@4
    17
#ifndef LIBXML2_XMLMEMORY_H
williamr@4
    18
#define LIBXML2_XMLMEMORY_H
williamr@4
    19
williamr@4
    20
#include <stddef.h>
williamr@4
    21
#include <stdapis/libxml2/libxml2_xmlversion.h>
williamr@4
    22
williamr@4
    23
williamr@4
    24
/**
williamr@4
    25
 * DEBUG_MEMORY:
williamr@4
    26
 *
williamr@4
    27
 * DEBUG_MEMORY replaces the allocator with a collect and debug
williamr@4
    28
 * shell to the libc allocator.
williamr@4
    29
 * DEBUG_MEMORY should only be activated when debugging
williamr@4
    30
 * libxml i.e. if libxml has been configured with --with-debug-mem too.
williamr@4
    31
 */
williamr@4
    32
/* #define DEBUG_MEMORY_FREED */
williamr@4
    33
/* #define DEBUG_MEMORY_LOCATION */
williamr@4
    34
williamr@4
    35
#ifdef DEBUG
williamr@4
    36
#ifndef DEBUG_MEMORY
williamr@4
    37
#define DEBUG_MEMORY
williamr@4
    38
#endif
williamr@4
    39
#endif
williamr@4
    40
williamr@4
    41
/**
williamr@4
    42
 * DEBUG_MEMORY_LOCATION:
williamr@4
    43
 *
williamr@4
    44
 * DEBUG_MEMORY_LOCATION should be activated only when debugging
williamr@4
    45
 * libxml i.e. if libxml has been configured with --with-debug-mem too.
williamr@4
    46
 */
williamr@4
    47
#ifdef DEBUG_MEMORY_LOCATION
williamr@4
    48
#endif
williamr@4
    49
williamr@4
    50
#ifdef __cplusplus
williamr@4
    51
extern "C" {
williamr@4
    52
#endif
williamr@4
    53
williamr@4
    54
/*
williamr@4
    55
 * The XML memory wrapper support 4 basic overloadable functions.
williamr@4
    56
 */
williamr@4
    57
/**
williamr@4
    58
 * xmlFreeFunc:
williamr@4
    59
 * @param mem an already allocated block of memory
williamr@4
    60
 *
williamr@4
    61
 * Signature for a free() implementation.
williamr@4
    62
 */
williamr@4
    63
typedef void (XMLCALL *xmlFreeFunc)(void *mem);
williamr@4
    64
/**
williamr@4
    65
 * xmlMallocFunc:
williamr@4
    66
 * @param size the size requested in bytes
williamr@4
    67
 *
williamr@4
    68
 * Signature for a malloc() implementation.
williamr@4
    69
 *
williamr@4
    70
 * Returns a pointer to the newly allocated block or NULL in case of error.
williamr@4
    71
 */
williamr@4
    72
typedef void *(XMLCALL *xmlMallocFunc)(size_t size);
williamr@4
    73
williamr@4
    74
/**
williamr@4
    75
 * xmlReallocFunc:
williamr@4
    76
 * @param mem an already allocated block of memory
williamr@4
    77
 * @param size the new size requested in bytes
williamr@4
    78
 *
williamr@4
    79
 * Signature for a realloc() implementation.
williamr@4
    80
 *
williamr@4
    81
 * Returns a pointer to the newly reallocated block or NULL in case of error.
williamr@4
    82
 */
williamr@4
    83
typedef void *(XMLCALL *xmlReallocFunc)(void *mem, size_t size);
williamr@4
    84
williamr@4
    85
/**
williamr@4
    86
 * xmlStrdupFunc:
williamr@4
    87
 * @param str a zero terminated string
williamr@4
    88
 *
williamr@4
    89
 * Signature for an strdup() implementation.
williamr@4
    90
 *
williamr@4
    91
 * Returns the copy of the string or NULL in case of error.
williamr@4
    92
 */
williamr@4
    93
typedef char *(XMLCALL *xmlStrdupFunc)(const char *str);
williamr@4
    94
williamr@4
    95
/*The 4 interfaces used for all memory handling within libxml.
williamr@4
    96
LIBXML_DLL_IMPORT extern xmlFreeFunc xmlFree;
williamr@4
    97
LIBXML_DLL_IMPORT extern xmlMallocFunc xmlMalloc;
williamr@4
    98
LIBXML_DLL_IMPORT extern xmlMallocFunc xmlMallocAtomic;
williamr@4
    99
LIBXML_DLL_IMPORT extern xmlReallocFunc xmlRealloc;
williamr@4
   100
LIBXML_DLL_IMPORT extern xmlStrdupFunc xmlMemStrdup;
williamr@4
   101
 */
williamr@4
   102
williamr@4
   103
/*
williamr@4
   104
 * The way to overload the existing functions.
williamr@4
   105
 * The xmlGc function have an extra entry for atomic block
williamr@4
   106
 * allocations useful for garbage collected memory allocators
williamr@4
   107
 */
williamr@4
   108
XMLPUBFUN int XMLCALL
williamr@4
   109
        xmlMemSetup     (xmlFreeFunc freeFunc,
williamr@4
   110
                         xmlMallocFunc mallocFunc,
williamr@4
   111
                         xmlReallocFunc reallocFunc,
williamr@4
   112
                         xmlStrdupFunc strdupFunc);
williamr@4
   113
XMLPUBFUN int XMLCALL
williamr@4
   114
        xmlMemGet       (xmlFreeFunc *freeFunc,
williamr@4
   115
                         xmlMallocFunc *mallocFunc,
williamr@4
   116
                         xmlReallocFunc *reallocFunc,
williamr@4
   117
                         xmlStrdupFunc *strdupFunc);
williamr@4
   118
williamr@4
   119
#ifndef XMLENGINE_EXCLUDE_UNUSED
williamr@4
   120
williamr@4
   121
XMLPUBFUN int XMLCALL
williamr@4
   122
        xmlGcMemSetup   (xmlFreeFunc freeFunc,
williamr@4
   123
                         xmlMallocFunc mallocFunc,
williamr@4
   124
                         xmlMallocFunc mallocAtomicFunc,
williamr@4
   125
                         xmlReallocFunc reallocFunc,
williamr@4
   126
                         xmlStrdupFunc strdupFunc);
williamr@4
   127
williamr@4
   128
XMLPUBFUN int XMLCALL
williamr@4
   129
        xmlGcMemGet     (xmlFreeFunc *freeFunc,
williamr@4
   130
                         xmlMallocFunc *mallocFunc,
williamr@4
   131
                         xmlMallocFunc *mallocAtomicFunc,
williamr@4
   132
                         xmlReallocFunc *reallocFunc,
williamr@4
   133
                         xmlStrdupFunc *strdupFunc);
williamr@4
   134
#endif /* ifndef XMLENGINE_EXCLUDE_UNUSED */
williamr@4
   135
williamr@4
   136
/*
williamr@4
   137
 * Initialization of the memory layer.
williamr@4
   138
 */
williamr@4
   139
XMLPUBFUN int XMLCALL
williamr@4
   140
        xmlInitMemory   (void);
williamr@4
   141
williamr@4
   142
/*
williamr@4
   143
 * Cleanup of the memory layer.
williamr@4
   144
 */
williamr@4
   145
XMLPUBFUN void XMLCALL
williamr@4
   146
                xmlCleanupMemory        (void);
williamr@4
   147
/*
williamr@4
   148
 * These are specific to the XML debug memory wrapper.
williamr@4
   149
 */
williamr@4
   150
XMLPUBFUN int XMLCALL
williamr@4
   151
        xmlMemUsed      (void);
williamr@4
   152
williamr@4
   153
#ifndef XMLENGINE_EXCLUDE_FILE_FUNC
williamr@4
   154
XMLPUBFUN void XMLCALL
williamr@4
   155
        xmlMemDisplay   (FILE *fp);
williamr@4
   156
XMLPUBFUN void XMLCALL
williamr@4
   157
        xmlMemShow      (FILE *fp, int nr);
williamr@4
   158
#endif
williamr@4
   159
williamr@4
   160
XMLPUBFUN void XMLCALL
williamr@4
   161
        xmlMemoryDump   (void);
williamr@4
   162
XMLPUBFUN void * XMLCALL
williamr@4
   163
        xmlMemMalloc    (size_t size);
williamr@4
   164
XMLPUBFUN void * XMLCALL
williamr@4
   165
        xmlMemRealloc   (void *ptr,size_t size);
williamr@4
   166
XMLPUBFUN void XMLCALL
williamr@4
   167
        xmlMemFree      (void *ptr);
williamr@4
   168
XMLPUBFUN char * XMLCALL
williamr@4
   169
        xmlMemoryStrdup (const char *str);
williamr@4
   170
XMLPUBFUN void * XMLCALL
williamr@4
   171
        xmlMallocLoc    (size_t size, const char *file, int line);
williamr@4
   172
XMLPUBFUN void * XMLCALL
williamr@4
   173
        xmlReallocLoc   (void *ptr, size_t size, const char *file, int line);
williamr@4
   174
XMLPUBFUN void * XMLCALL
williamr@4
   175
        xmlMallocAtomicLoc (size_t size, const char *file, int line);
williamr@4
   176
XMLPUBFUN char * XMLCALL
williamr@4
   177
        xmlMemStrdupLoc (const char *str, const char *file, int line);
williamr@4
   178
williamr@4
   179
williamr@4
   180
#ifdef DEBUG_MEMORY_LOCATION
williamr@4
   181
/**
williamr@4
   182
 * xmlMalloc:
williamr@4
   183
 * @param size number of bytes to allocate
williamr@4
   184
 *
williamr@4
   185
 * Wrapper for the malloc() function used in the XML library.
williamr@4
   186
 *
williamr@4
   187
 * Returns the pointer to the allocated area or NULL in case of error.
williamr@4
   188
 */
williamr@4
   189
#define xmlMalloc(size) xmlMallocLoc((size), __FILE__, __LINE__)
williamr@4
   190
/**
williamr@4
   191
 * xmlMallocAtomic:
williamr@4
   192
 * @param size number of bytes to allocate
williamr@4
   193
 *
williamr@4
   194
 * Wrapper for the malloc() function used in the XML library for allocation
williamr@4
   195
 * of block not containing pointers to other areas.
williamr@4
   196
 *
williamr@4
   197
 * Returns the pointer to the allocated area or NULL in case of error.
williamr@4
   198
 */
williamr@4
   199
#define xmlMallocAtomic(size) xmlMallocAtomicLoc((size), __FILE__, __LINE__)
williamr@4
   200
/**
williamr@4
   201
 * xmlRealloc:
williamr@4
   202
 * @param ptr pointer to the existing allocated area
williamr@4
   203
 * @param size number of bytes to allocate
williamr@4
   204
 *
williamr@4
   205
 * Wrapper for the realloc() function used in the XML library.
williamr@4
   206
 *
williamr@4
   207
 * Returns the pointer to the allocated area or NULL in case of error.
williamr@4
   208
 */
williamr@4
   209
#define xmlRealloc(ptr, size) xmlReallocLoc((ptr), (size), __FILE__, __LINE__)
williamr@4
   210
/**
williamr@4
   211
 * xmlMemStrdup:
williamr@4
   212
 * @param str pointer to the existing string
williamr@4
   213
 *
williamr@4
   214
 * Wrapper for the strdup() function, xmlStrdup() is usually preferred.
williamr@4
   215
 *
williamr@4
   216
 * Returns the pointer to the allocated area or NULL in case of error.
williamr@4
   217
 */
williamr@4
   218
#define xmlMemStrdup(str) xmlMemStrdupLoc((str), __FILE__, __LINE__)
williamr@4
   219
williamr@4
   220
#endif /* DEBUG_MEMORY_LOCATION */
williamr@4
   221
williamr@4
   222
#ifdef __cplusplus
williamr@4
   223
}
williamr@4
   224
#endif /* __cplusplus */
williamr@4
   225
williamr@4
   226
williamr@4
   227
#endif  /* LIBXML2_MEMORY_H */