Blame os400/libxmlrpg/xmlmemory.rpgle

Packit Service a31ea6
      * Summary: interface for the memory allocator
Packit Service a31ea6
      * Description: provides interfaces for the memory allocator,
Packit Service a31ea6
      *              including debugging capabilities.
Packit Service a31ea6
      *
Packit Service a31ea6
      * Copy: See Copyright for the status of this software.
Packit Service a31ea6
      *
Packit Service a31ea6
      * Author: Patrick Monnerat <pm@datasphere.ch>, DATASPHERE S.A.
Packit Service a31ea6
Packit Service a31ea6
      /if not defined(DEBUG_MEMORY_ALLOC__)
Packit Service a31ea6
      /define DEBUG_MEMORY_ALLOC__
Packit Service a31ea6
Packit Service a31ea6
      /include "libxmlrpg/xmlversion"
Packit Service a31ea6
      /include "libxmlrpg/xmlTypesC"
Packit Service a31ea6
Packit Service a31ea6
      * DEBUG_MEMORY:
Packit Service a31ea6
      *
Packit Service a31ea6
      * DEBUG_MEMORY replaces the allocator with a collect and debug
Packit Service a31ea6
      * shell to the libc allocator.
Packit Service a31ea6
      * DEBUG_MEMORY should only be activated when debugging
Packit Service a31ea6
      * libxml i.e. if libxml has been configured with --with-debug-mem too.
Packit Service a31ea6
Packit Service a31ea6
      * /define DEBUG_MEMORY_FREED
Packit Service a31ea6
      * /define DEBUG_MEMORY_LOCATION
Packit Service a31ea6
Packit Service a31ea6
      /if defined(DEBUG)
Packit Service a31ea6
      /if not defined(DEBUG_MEMORY)
Packit Service a31ea6
      /define DEBUG_MEMORY
Packit Service a31ea6
      /endif
Packit Service a31ea6
      /endif
Packit Service a31ea6
Packit Service a31ea6
      * DEBUG_MEMORY_LOCATION:
Packit Service a31ea6
      *
Packit Service a31ea6
      * DEBUG_MEMORY_LOCATION should be activated only when debugging
Packit Service a31ea6
      * libxml i.e. if libxml has been configured with --with-debug-mem too.
Packit Service a31ea6
Packit Service a31ea6
      /if defined(DEBUG_MEMORY_LOCATION)
Packit Service a31ea6
      /endif
Packit Service a31ea6
Packit Service a31ea6
      * The XML memory wrapper support 4 basic overloadable functions.
Packit Service a31ea6
Packit Service a31ea6
      * xmlFreeFunc:
Packit Service a31ea6
      * @mem: an already allocated block of memory
Packit Service a31ea6
      *
Packit Service a31ea6
      * Signature for a free() implementation.
Packit Service a31ea6
Packit Service a31ea6
     d xmlFreeFunc     s               *   based(######typedef######)
Packit Service a31ea6
     d                                     procptr
Packit Service a31ea6
Packit Service a31ea6
      * xmlMallocFunc:
Packit Service a31ea6
      * @size:  the size requested in bytes
Packit Service a31ea6
      *
Packit Service a31ea6
      * Signature for a malloc() implementation.
Packit Service a31ea6
      *
Packit Service a31ea6
      * Returns a pointer to the newly allocated block or NULL in case of error.
Packit Service a31ea6
Packit Service a31ea6
     d xmlMallocFunc   s               *   based(######typedef######)
Packit Service a31ea6
     d                                     procptr
Packit Service a31ea6
Packit Service a31ea6
      * xmlReallocFunc:
Packit Service a31ea6
      * @mem: an already allocated block of memory
Packit Service a31ea6
      * @size:  the new size requested in bytes
Packit Service a31ea6
      *
Packit Service a31ea6
      * Signature for a realloc() implementation.
Packit Service a31ea6
      *
Packit Service a31ea6
      * Returns a pointer to the newly reallocated block or NULL in case of error.
Packit Service a31ea6
Packit Service a31ea6
     d xmlReallocFunc  s               *   based(######typedef######)
Packit Service a31ea6
     d                                     procptr
Packit Service a31ea6
Packit Service a31ea6
      * xmlStrdupFunc:
Packit Service a31ea6
      * @str: a zero terminated string
Packit Service a31ea6
      *
Packit Service a31ea6
      * Signature for an strdup() implementation.
Packit Service a31ea6
      *
Packit Service a31ea6
      * Returns the copy of the string or NULL in case of error.
Packit Service a31ea6
Packit Service a31ea6
     d xmlStrdupFunc   s               *   based(######typedef######)
Packit Service a31ea6
     d                                     procptr
Packit Service a31ea6
Packit Service a31ea6
      * The 5 interfaces used for all memory handling within libxml.
Packit Service a31ea6
      * Since indirect calls are only supported via a based prototype,
Packit Service a31ea6
      *   storage is accessed via functions.
Packit Service a31ea6
Packit Service a31ea6
     d get_xmlFree     pr                  extproc('__get_xmlFree')
Packit Service a31ea6
     d                                     like(xmlFreeFunc)
Packit Service a31ea6
Packit Service a31ea6
     d set_xmlFree     pr                  extproc('__set_xmlFree')
Packit Service a31ea6
     d  func                               value like(xmlFreeFunc)
Packit Service a31ea6
Packit Service a31ea6
     d xmlFree         pr                  extproc('__call_xmlFree')
Packit Service a31ea6
     d  mem                            *   value                                void *
Packit Service a31ea6
Packit Service a31ea6
     d get_xmlMalloc   pr                  extproc('__get_xmlMalloc')
Packit Service a31ea6
     d                                     like(xmlMallocFunc)
Packit Service a31ea6
Packit Service a31ea6
     d set_xmlMalloc   pr                  extproc('__set_xmlMalloc')
Packit Service a31ea6
     d  func                               value like(xmlMallocFunc)
Packit Service a31ea6
Packit Service a31ea6
     d xmlMalloc       pr              *   extproc('__call_xmlMalloc')          void *
Packit Service a31ea6
     d  size                               value like(xmlCsize_t)
Packit Service a31ea6
Packit Service a31ea6
     d get_xmlMallocAtomic...
Packit Service a31ea6
     d                 pr                  extproc('__get_xmlMallocAtomic')
Packit Service a31ea6
     d                                     like(xmlMallocFunc)
Packit Service a31ea6
Packit Service a31ea6
     d set_xmlMallocAtomic...
Packit Service a31ea6
     d                 pr                  extproc('__set_xmlMallocAtomic')
Packit Service a31ea6
     d  func                               value like(xmlMallocFunc)
Packit Service a31ea6
Packit Service a31ea6
     d xmlMallocAtomic...
Packit Service a31ea6
     d                 pr              *   extproc('__call_xmlMallocAtomic')    void *
Packit Service a31ea6
     d  size                               value like(xmlCsize_t)
Packit Service a31ea6
Packit Service a31ea6
     d get_xmlRealloc  pr                  extproc('__get_xmlRealloc')
Packit Service a31ea6
     d                                     like(xmlReallocFunc)
Packit Service a31ea6
Packit Service a31ea6
     d set_xmlRealloc  pr                  extproc('__set_xmlRealloc')
Packit Service a31ea6
     d  func                               value like(xmlReallocFunc)
Packit Service a31ea6
Packit Service a31ea6
     d xmlRealloc      pr              *   extproc('__call_xmlRealloc')         void *
Packit Service a31ea6
     d  mem                            *   value                                void *
Packit Service a31ea6
     d  size                               value like(xmlCsize_t)
Packit Service a31ea6
Packit Service a31ea6
     d get_xmlMemStrdup...
Packit Service a31ea6
     d                 pr                  extproc('__get_xmlMemStrdup')
Packit Service a31ea6
     d                                     like(xmlStrdupFunc)
Packit Service a31ea6
Packit Service a31ea6
     d set_xmlMemStrdup...
Packit Service a31ea6
     d                 pr                  extproc('__set_xmlMemstrdup')
Packit Service a31ea6
     d  func                               value like(xmlStrdupFunc)
Packit Service a31ea6
Packit Service a31ea6
     d xmlMemStrdup    pr              *   extproc('__call_xmlMemStrdup')          void *
Packit Service a31ea6
     d  str                            *   value options(*string)               const char *
Packit Service a31ea6
Packit Service a31ea6
      * The way to overload the existing functions.
Packit Service a31ea6
      * The xmlGc function have an extra entry for atomic block
Packit Service a31ea6
      * allocations useful for garbage collected memory allocators
Packit Service a31ea6
Packit Service a31ea6
     d xmlMemSetup     pr                  extproc('xmlMemSetup')
Packit Service a31ea6
     d                                     like(xmlCint)
Packit Service a31ea6
     d  freeFunc                           value like(xmlFreeFunc)
Packit Service a31ea6
     d  mallocFunc                         value like(xmlMallocFunc)
Packit Service a31ea6
     d  reallocFunc                        value like(xmlReallocFunc)
Packit Service a31ea6
     d  strdupFunc                         value like(xmlStrdupFunc)
Packit Service a31ea6
Packit Service a31ea6
     d xmlMemGet       pr                  extproc('xmlMemGet')
Packit Service a31ea6
     d                                     like(xmlCint)
Packit Service a31ea6
     d  freeFunc                           like(xmlFreeFunc)
Packit Service a31ea6
     d  mallocFunc                         like(xmlMallocFunc)
Packit Service a31ea6
     d  reallocFunc                        like(xmlReallocFunc)
Packit Service a31ea6
     d  strdupFunc                         like(xmlStrdupFunc)
Packit Service a31ea6
Packit Service a31ea6
     d xmlGcMemSetup   pr                  extproc('xmlGcMemSetup')
Packit Service a31ea6
     d                                     like(xmlCint)
Packit Service a31ea6
     d  freeFunc                           value like(xmlFreeFunc)
Packit Service a31ea6
     d  mallocFunc                         value like(xmlMallocFunc)
Packit Service a31ea6
     d  mallocAtomicFunc...
Packit Service a31ea6
     d                                     value like(xmlMallocFunc)
Packit Service a31ea6
     d  reallocFunc                        value like(xmlReallocFunc)
Packit Service a31ea6
     d  strdupFunc                         value like(xmlStrdupFunc)
Packit Service a31ea6
Packit Service a31ea6
     d xmlGcMemGet     pr                  extproc('xmlGcMemGet')
Packit Service a31ea6
     d                                     like(xmlCint)
Packit Service a31ea6
     d  freeFunc                           like(xmlFreeFunc)
Packit Service a31ea6
     d  mallocFunc                         like(xmlMallocFunc)
Packit Service a31ea6
     d  mallocAtomicFunc...
Packit Service a31ea6
     d                                     like(xmlMallocFunc)
Packit Service a31ea6
     d  reallocFunc                        like(xmlReallocFunc)
Packit Service a31ea6
     d  strdupFunc                         like(xmlStrdupFunc)
Packit Service a31ea6
Packit Service a31ea6
      * Initialization of the memory layer.
Packit Service a31ea6
Packit Service a31ea6
     d xmlInitMemory   pr                  extproc('xmlInitMemory')
Packit Service a31ea6
     d                                     like(xmlCint)
Packit Service a31ea6
Packit Service a31ea6
      * Cleanup of the memory layer.
Packit Service a31ea6
Packit Service a31ea6
     d xmlCleanupMemory...
Packit Service a31ea6
     d                 pr                  extproc('xmlCleanupMemory')
Packit Service a31ea6
Packit Service a31ea6
      * These are specific to the XML debug memory wrapper.
Packit Service a31ea6
Packit Service a31ea6
     d xmlMemUsed      pr                  extproc('xmlMemUsed')
Packit Service a31ea6
     d                                     like(xmlCint)
Packit Service a31ea6
Packit Service a31ea6
     d xmlMemBlocks    pr                  extproc('xmlMemBlocks')
Packit Service a31ea6
     d                                     like(xmlCint)
Packit Service a31ea6
Packit Service a31ea6
     d xmlMemDisplay   pr                  extproc('xmlMemDisplay')
Packit Service a31ea6
     d  fp                             *   value                                FILE *
Packit Service a31ea6
Packit Service a31ea6
     d xmlMmDisplayLast...
Packit Service a31ea6
     d                 pr                  extproc('xmlMemDisplayLast')
Packit Service a31ea6
     d  fp                             *   value                                FILE *
Packit Service a31ea6
     d  nbBytes                            value like(xmlClong)
Packit Service a31ea6
Packit Service a31ea6
     d xmlMemShow      pr                  extproc('xmlMemShow')
Packit Service a31ea6
     d  fp                             *   value                                FILE *
Packit Service a31ea6
     d  nr                                 value like(xmlCint)
Packit Service a31ea6
Packit Service a31ea6
     d xmlMemoryDump   pr                  extproc('xmlMemoryDump')
Packit Service a31ea6
Packit Service a31ea6
     d xmlMemMalloc    pr              *   extproc('xmlMemMalloc')              void *
Packit Service a31ea6
     d  size                               value like(xmlCsize_t)
Packit Service a31ea6
Packit Service a31ea6
     d xmlMemRealloc   pr              *   extproc('xmlMemRealloc')             void *
Packit Service a31ea6
     d  ptr                            *   value                                void *
Packit Service a31ea6
     d  size                               value like(xmlCsize_t)
Packit Service a31ea6
Packit Service a31ea6
     d xmlMemFree      pr                  extproc('xmlMemFree')
Packit Service a31ea6
     d  ptr                            *   value                                void *
Packit Service a31ea6
Packit Service a31ea6
     d xmlMemoryStrdup...
Packit Service a31ea6
     d                 pr              *   extproc('xmlMemoryStrdup')           char *
Packit Service a31ea6
     d  str                            *   value options(*string)               const char *
Packit Service a31ea6
Packit Service a31ea6
     d xmlMallocLoc    pr              *   extproc('xmlMallocLoc')              void *
Packit Service a31ea6
     d  size                               value like(xmlCsize_t)
Packit Service a31ea6
     d  file                           *   value options(*string)               const char *
Packit Service a31ea6
     d  line                               value like(xmlCint)
Packit Service a31ea6
Packit Service a31ea6
     d xmlReallocLoc   pr              *   extproc('xmlReallocLoc')              void *
Packit Service a31ea6
     d  ptr                            *   value                                void *
Packit Service a31ea6
     d  size                               value like(xmlCsize_t)
Packit Service a31ea6
     d  file                           *   value options(*string)               const char *
Packit Service a31ea6
     d  line                               value like(xmlCint)
Packit Service a31ea6
Packit Service a31ea6
     d xmlMallocAtomicLoc...
Packit Service a31ea6
     d                 pr              *   extproc('xmlMallocAtomicLoc')        void *
Packit Service a31ea6
     d  size                               value like(xmlCsize_t)
Packit Service a31ea6
     d  file                           *   value options(*string)               const char *
Packit Service a31ea6
     d  line                               value like(xmlCint)
Packit Service a31ea6
Packit Service a31ea6
     d xmlMemStrdupLoc...
Packit Service a31ea6
     d                 pr              *   extproc('xmlMemStrdupLoc')           char *
Packit Service a31ea6
     d  str                            *   value options(*string)               const char *
Packit Service a31ea6
     d  file                           *   value options(*string)               const char *
Packit Service a31ea6
     d  line                               value like(xmlCint)
Packit Service a31ea6
Packit Service a31ea6
      /if not defined(XML_GLOBALS_H)
Packit Service a31ea6
      /if not defined(XML_THREADS_H__)
Packit Service a31ea6
      /include "libxmlrpg/threads"
Packit Service a31ea6
      /include "libxmlrpg/globals"
Packit Service a31ea6
      /endif
Packit Service a31ea6
      /endif
Packit Service a31ea6
Packit Service a31ea6
      /endif                                                                    DEBUG_MEMORY_ALLOC__