epoc32/include/stdapis/libxml2/libxml2_xmlmemory.h
branchSymbian3
changeset 4 837f303aceeb
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/stdapis/libxml2/libxml2_xmlmemory.h	Wed Mar 31 12:33:34 2010 +0100
     1.3 @@ -0,0 +1,227 @@
     1.4 +/*
     1.5 + * Summary: interface for the memory allocator
     1.6 + * Description: provides interfaces for the memory allocator,
     1.7 + *              including debugging capabilities.
     1.8 + *
     1.9 + * Copy: See Copyright for the status of this software.
    1.10 + *
    1.11 + * Author: Daniel Veillard
    1.12 + * Portion Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. 
    1.13 + */
    1.14 +
    1.15 +/** @file
    1.16 +@publishedAll
    1.17 +@released
    1.18 +*/
    1.19 +
    1.20 +#ifndef LIBXML2_XMLMEMORY_H
    1.21 +#define LIBXML2_XMLMEMORY_H
    1.22 +
    1.23 +#include <stddef.h>
    1.24 +#include <stdapis/libxml2/libxml2_xmlversion.h>
    1.25 +
    1.26 +
    1.27 +/**
    1.28 + * DEBUG_MEMORY:
    1.29 + *
    1.30 + * DEBUG_MEMORY replaces the allocator with a collect and debug
    1.31 + * shell to the libc allocator.
    1.32 + * DEBUG_MEMORY should only be activated when debugging
    1.33 + * libxml i.e. if libxml has been configured with --with-debug-mem too.
    1.34 + */
    1.35 +/* #define DEBUG_MEMORY_FREED */
    1.36 +/* #define DEBUG_MEMORY_LOCATION */
    1.37 +
    1.38 +#ifdef DEBUG
    1.39 +#ifndef DEBUG_MEMORY
    1.40 +#define DEBUG_MEMORY
    1.41 +#endif
    1.42 +#endif
    1.43 +
    1.44 +/**
    1.45 + * DEBUG_MEMORY_LOCATION:
    1.46 + *
    1.47 + * DEBUG_MEMORY_LOCATION should be activated only when debugging
    1.48 + * libxml i.e. if libxml has been configured with --with-debug-mem too.
    1.49 + */
    1.50 +#ifdef DEBUG_MEMORY_LOCATION
    1.51 +#endif
    1.52 +
    1.53 +#ifdef __cplusplus
    1.54 +extern "C" {
    1.55 +#endif
    1.56 +
    1.57 +/*
    1.58 + * The XML memory wrapper support 4 basic overloadable functions.
    1.59 + */
    1.60 +/**
    1.61 + * xmlFreeFunc:
    1.62 + * @param mem an already allocated block of memory
    1.63 + *
    1.64 + * Signature for a free() implementation.
    1.65 + */
    1.66 +typedef void (XMLCALL *xmlFreeFunc)(void *mem);
    1.67 +/**
    1.68 + * xmlMallocFunc:
    1.69 + * @param size the size requested in bytes
    1.70 + *
    1.71 + * Signature for a malloc() implementation.
    1.72 + *
    1.73 + * Returns a pointer to the newly allocated block or NULL in case of error.
    1.74 + */
    1.75 +typedef void *(XMLCALL *xmlMallocFunc)(size_t size);
    1.76 +
    1.77 +/**
    1.78 + * xmlReallocFunc:
    1.79 + * @param mem an already allocated block of memory
    1.80 + * @param size the new size requested in bytes
    1.81 + *
    1.82 + * Signature for a realloc() implementation.
    1.83 + *
    1.84 + * Returns a pointer to the newly reallocated block or NULL in case of error.
    1.85 + */
    1.86 +typedef void *(XMLCALL *xmlReallocFunc)(void *mem, size_t size);
    1.87 +
    1.88 +/**
    1.89 + * xmlStrdupFunc:
    1.90 + * @param str a zero terminated string
    1.91 + *
    1.92 + * Signature for an strdup() implementation.
    1.93 + *
    1.94 + * Returns the copy of the string or NULL in case of error.
    1.95 + */
    1.96 +typedef char *(XMLCALL *xmlStrdupFunc)(const char *str);
    1.97 +
    1.98 +/*The 4 interfaces used for all memory handling within libxml.
    1.99 +LIBXML_DLL_IMPORT extern xmlFreeFunc xmlFree;
   1.100 +LIBXML_DLL_IMPORT extern xmlMallocFunc xmlMalloc;
   1.101 +LIBXML_DLL_IMPORT extern xmlMallocFunc xmlMallocAtomic;
   1.102 +LIBXML_DLL_IMPORT extern xmlReallocFunc xmlRealloc;
   1.103 +LIBXML_DLL_IMPORT extern xmlStrdupFunc xmlMemStrdup;
   1.104 + */
   1.105 +
   1.106 +/*
   1.107 + * The way to overload the existing functions.
   1.108 + * The xmlGc function have an extra entry for atomic block
   1.109 + * allocations useful for garbage collected memory allocators
   1.110 + */
   1.111 +XMLPUBFUN int XMLCALL
   1.112 +        xmlMemSetup     (xmlFreeFunc freeFunc,
   1.113 +                         xmlMallocFunc mallocFunc,
   1.114 +                         xmlReallocFunc reallocFunc,
   1.115 +                         xmlStrdupFunc strdupFunc);
   1.116 +XMLPUBFUN int XMLCALL
   1.117 +        xmlMemGet       (xmlFreeFunc *freeFunc,
   1.118 +                         xmlMallocFunc *mallocFunc,
   1.119 +                         xmlReallocFunc *reallocFunc,
   1.120 +                         xmlStrdupFunc *strdupFunc);
   1.121 +
   1.122 +#ifndef XMLENGINE_EXCLUDE_UNUSED
   1.123 +
   1.124 +XMLPUBFUN int XMLCALL
   1.125 +        xmlGcMemSetup   (xmlFreeFunc freeFunc,
   1.126 +                         xmlMallocFunc mallocFunc,
   1.127 +                         xmlMallocFunc mallocAtomicFunc,
   1.128 +                         xmlReallocFunc reallocFunc,
   1.129 +                         xmlStrdupFunc strdupFunc);
   1.130 +
   1.131 +XMLPUBFUN int XMLCALL
   1.132 +        xmlGcMemGet     (xmlFreeFunc *freeFunc,
   1.133 +                         xmlMallocFunc *mallocFunc,
   1.134 +                         xmlMallocFunc *mallocAtomicFunc,
   1.135 +                         xmlReallocFunc *reallocFunc,
   1.136 +                         xmlStrdupFunc *strdupFunc);
   1.137 +#endif /* ifndef XMLENGINE_EXCLUDE_UNUSED */
   1.138 +
   1.139 +/*
   1.140 + * Initialization of the memory layer.
   1.141 + */
   1.142 +XMLPUBFUN int XMLCALL
   1.143 +        xmlInitMemory   (void);
   1.144 +
   1.145 +/*
   1.146 + * Cleanup of the memory layer.
   1.147 + */
   1.148 +XMLPUBFUN void XMLCALL
   1.149 +                xmlCleanupMemory        (void);
   1.150 +/*
   1.151 + * These are specific to the XML debug memory wrapper.
   1.152 + */
   1.153 +XMLPUBFUN int XMLCALL
   1.154 +        xmlMemUsed      (void);
   1.155 +
   1.156 +#ifndef XMLENGINE_EXCLUDE_FILE_FUNC
   1.157 +XMLPUBFUN void XMLCALL
   1.158 +        xmlMemDisplay   (FILE *fp);
   1.159 +XMLPUBFUN void XMLCALL
   1.160 +        xmlMemShow      (FILE *fp, int nr);
   1.161 +#endif
   1.162 +
   1.163 +XMLPUBFUN void XMLCALL
   1.164 +        xmlMemoryDump   (void);
   1.165 +XMLPUBFUN void * XMLCALL
   1.166 +        xmlMemMalloc    (size_t size);
   1.167 +XMLPUBFUN void * XMLCALL
   1.168 +        xmlMemRealloc   (void *ptr,size_t size);
   1.169 +XMLPUBFUN void XMLCALL
   1.170 +        xmlMemFree      (void *ptr);
   1.171 +XMLPUBFUN char * XMLCALL
   1.172 +        xmlMemoryStrdup (const char *str);
   1.173 +XMLPUBFUN void * XMLCALL
   1.174 +        xmlMallocLoc    (size_t size, const char *file, int line);
   1.175 +XMLPUBFUN void * XMLCALL
   1.176 +        xmlReallocLoc   (void *ptr, size_t size, const char *file, int line);
   1.177 +XMLPUBFUN void * XMLCALL
   1.178 +        xmlMallocAtomicLoc (size_t size, const char *file, int line);
   1.179 +XMLPUBFUN char * XMLCALL
   1.180 +        xmlMemStrdupLoc (const char *str, const char *file, int line);
   1.181 +
   1.182 +
   1.183 +#ifdef DEBUG_MEMORY_LOCATION
   1.184 +/**
   1.185 + * xmlMalloc:
   1.186 + * @param size number of bytes to allocate
   1.187 + *
   1.188 + * Wrapper for the malloc() function used in the XML library.
   1.189 + *
   1.190 + * Returns the pointer to the allocated area or NULL in case of error.
   1.191 + */
   1.192 +#define xmlMalloc(size) xmlMallocLoc((size), __FILE__, __LINE__)
   1.193 +/**
   1.194 + * xmlMallocAtomic:
   1.195 + * @param size number of bytes to allocate
   1.196 + *
   1.197 + * Wrapper for the malloc() function used in the XML library for allocation
   1.198 + * of block not containing pointers to other areas.
   1.199 + *
   1.200 + * Returns the pointer to the allocated area or NULL in case of error.
   1.201 + */
   1.202 +#define xmlMallocAtomic(size) xmlMallocAtomicLoc((size), __FILE__, __LINE__)
   1.203 +/**
   1.204 + * xmlRealloc:
   1.205 + * @param ptr pointer to the existing allocated area
   1.206 + * @param size number of bytes to allocate
   1.207 + *
   1.208 + * Wrapper for the realloc() function used in the XML library.
   1.209 + *
   1.210 + * Returns the pointer to the allocated area or NULL in case of error.
   1.211 + */
   1.212 +#define xmlRealloc(ptr, size) xmlReallocLoc((ptr), (size), __FILE__, __LINE__)
   1.213 +/**
   1.214 + * xmlMemStrdup:
   1.215 + * @param str pointer to the existing string
   1.216 + *
   1.217 + * Wrapper for the strdup() function, xmlStrdup() is usually preferred.
   1.218 + *
   1.219 + * Returns the pointer to the allocated area or NULL in case of error.
   1.220 + */
   1.221 +#define xmlMemStrdup(str) xmlMemStrdupLoc((str), __FILE__, __LINE__)
   1.222 +
   1.223 +#endif /* DEBUG_MEMORY_LOCATION */
   1.224 +
   1.225 +#ifdef __cplusplus
   1.226 +}
   1.227 +#endif /* __cplusplus */
   1.228 +
   1.229 +
   1.230 +#endif  /* LIBXML2_MEMORY_H */