My Project
Loading...
Searching...
No Matches
omMallocSystem.h
Go to the documentation of this file.
1/*******************************************************************
2 * File: omMallocSystem.h
3 * Purpose: declaration of macros for malloc to be used from the system
4 * Author: obachman (Olaf Bachmann)
5 * Created: 11/99
6 *******************************************************************/
7#ifndef OM_MALLOC_SYSTEM_H
8#define OM_MALLOC_SYSTEM_H
9
10/* this is the minimal set of OM_MALLOC_* macros which must be defined */
11#define OM_MALLOC_MALLOC malloc
12#define OM_MALLOC_REALLOC realloc
13#define OM_MALLOC_FREE free
14#define OM_MALLOC_VALLOC valloc
15#define OM_MALLOC_VFREE(addr, size) OM_MALLOC_FREE(addr)
16#ifdef HAVE_MALLOC_SIZE
17/* the following will work under Mac OS X */
18 #ifdef HAVE_MALLOC_H
19 #include <malloc.h>
20 #elif defined(HAVE_MALLOC_MALLOC_H)
21 #include <malloc/malloc.h>
22 #endif
23 #define OM_MALLOC_SIZEOF_ADDR(addr) (malloc_size(addr))
24#elif (defined(HAVE_MALLOC_USABLE_SIZE))
25/* and this will work under Linux */
26#include <stdlib.h>
27#define OM_MALLOC_SIZEOF_ADDR(addr) (malloc_usable_size(addr))
28#else
29static inline size_t OM_MALLOC_SIZEOF_ADDR(void *d) { long*dd=(long*)d; return *(dd-1); }
30#endif
31
32#endif /* OM_MALLOC_SYSTEM_H */
static size_t OM_MALLOC_SIZEOF_ADDR(void *d)