mdMalloc, mdFree, mdCallMalloc, mdCallFree, mdSetAllocator - control
memory allocation for the MIDI library
typedef void *(*mdMalloc_t)(size_t);
typedef void (*mdFree_t)(void *);
void mdSetAllocator(mdMalloc_t malloc_func, mdFree_t free_func, void *ap)
mdMalloc and mdFree are pointers to memory allocation functions used by
the MIDI library. The default implementations use the amalloc(3P)
library to implement an arena separate from the main heap used by
malloc(3C). This allows memory performance in the MIDI library to be
maintained in the presence of high malloc usage by an application.
mdMalloc is used by mdReceive(3dm) to allocate storage for incoming MIDI
system exclusive messages. mdFree is used by the application to release
mdMalloc and mdFree are mp-safe.
mdSetAllocator allows an application to override the any of the
following: mdMalloc (via malloc_func), mdFree (via free_func) or the
storage arena (via ap). When using one's own arena, the default behavior
of the storage allocator may be changed via amallopt(3P). If all three
are overridden, the behavior of the storage allocator is completely under
mdCallMalloc and mdCallFree are routines used to call the current
allocation or deallocation routine, respectively. These are actual
routines, not pointers.
mdMalloc returns a pointer to a block of memory at least len bytes long,
or NULL if no storage can be allocated.
PPPPaaaaggggeeee 1111 [ Back ]