summaryrefslogtreecommitdiff
path: root/src/common/malloc.h
diff options
context:
space:
mode:
authorshennetsind <ind@henn.et>2013-05-17 22:03:06 -0300
committershennetsind <ind@henn.et>2013-05-17 22:03:06 -0300
commit21bbfad48084190b8a6881ee3b277993418a5137 (patch)
tree2c8cf1d4a83bb0a7bea2a7e81c003fc240185207 /src/common/malloc.h
parent104bb6c05dc8effef9db715f0b708d4548e10010 (diff)
parentb3bc657a44a9fbdd1730f569855e25ccd0f8dd01 (diff)
downloadhercules-21bbfad48084190b8a6881ee3b277993418a5137.tar.gz
hercules-21bbfad48084190b8a6881ee3b277993418a5137.tar.bz2
hercules-21bbfad48084190b8a6881ee3b277993418a5137.tar.xz
hercules-21bbfad48084190b8a6881ee3b277993418a5137.zip
Follow up b3bc657a44a9fbdd1730f569855e25ccd0f8dd01
Adjusting it to the ERS modification, my IDE automatically fixed some indentation that i guess was accidentally removed. Signed-off-by: shennetsind <ind@henn.et>
Diffstat (limited to 'src/common/malloc.h')
-rw-r--r--src/common/malloc.h74
1 files changed, 33 insertions, 41 deletions
diff --git a/src/common/malloc.h b/src/common/malloc.h
index 6b4e8e5c4..34a26b56e 100644
--- a/src/common/malloc.h
+++ b/src/common/malloc.h
@@ -22,57 +22,32 @@
//////////////////////////////////////////////////////////////////////
-// Athena's built-in Memory Manager
-#ifdef USE_MEMMGR
-
// Enable memory manager logging by default
#define LOG_MEMMGR
// no logging for minicore
#if defined(MINICORE) && defined(LOG_MEMMGR)
-#undef LOG_MEMMGR
+ #undef LOG_MEMMGR
#endif
-# define aMalloc(n) _mmalloc(n,ALC_MARK)
-# define aCalloc(m,n) _mcalloc(m,n,ALC_MARK)
-# define aRealloc(p,n) _mrealloc(p,n,ALC_MARK)
-# define aStrdup(p) _mstrdup(p,ALC_MARK)
-# define aFree(p) _mfree(p,ALC_MARK)
-
- void* _mmalloc (size_t size, const char *file, int line, const char *func);
- void* _mcalloc (size_t num, size_t size, const char *file, int line, const char *func);
- void* _mrealloc (void *p, size_t size, const char *file, int line, const char *func);
- char* _mstrdup (const char *p, const char *file, int line, const char *func);
- void _mfree (void *p, const char *file, int line, const char *func);
-
-#else
-
-# define aMalloc(n) aMalloc_((n),ALC_MARK)
-# define aCalloc(m,n) aCalloc_((m),(n),ALC_MARK)
-# define aRealloc(p,n) aRealloc_(p,n,ALC_MARK)
-# define aStrdup(p) aStrdup_(p,ALC_MARK)
-# define aFree(p) aFree_(p,ALC_MARK)
-
- void* aMalloc_ (size_t size, const char *file, int line, const char *func);
- void* aCalloc_ (size_t num, size_t size, const char *file, int line, const char *func);
- void* aRealloc_ (void *p, size_t size, const char *file, int line, const char *func);
- char* aStrdup_ (const char *p, const char *file, int line, const char *func);
- void aFree_ (void *p, const char *file, int line, const char *func);
-
-#endif
+# define aMalloc(n) malloclib->malloc (n,ALC_MARK)
+# define aCalloc(m,n) malloclib->calloc (m,n,ALC_MARK)
+# define aRealloc(p,n) malloclib->realloc (p,n,ALC_MARK)
+# define aStrdup(p) malloclib->astrdup (p,ALC_MARK)
+# define aFree(p) malloclib->free (p,ALC_MARK)
/////////////// Buffer Creation /////////////////
// Full credit for this goes to Shinomori [Ajarn]
#ifdef __GNUC__ // GCC has variable length arrays
- #define CREATE_BUFFER(name, type, size) type name[size]
- #define DELETE_BUFFER(name)
+#define CREATE_BUFFER(name, type, size) type name[size]
+#define DELETE_BUFFER(name)
#else // others don't, so we emulate them
- #define CREATE_BUFFER(name, type, size) type *name = (type *) aCalloc (size, sizeof(type))
- #define DELETE_BUFFER(name) aFree(name)
+#define CREATE_BUFFER(name, type, size) type *name = (type *) aCalloc (size, sizeof(type))
+#define DELETE_BUFFER(name) aFree(name)
#endif
@@ -83,10 +58,27 @@
////////////////////////////////////////////////
-void malloc_memory_check(void);
-bool malloc_verify_ptr(void* ptr);
-size_t malloc_usage (void);
-void malloc_init (void);
-void malloc_final (void);
-
+//void malloc_memory_check(void);
+//bool malloc_verify_ptr(void* ptr);
+//size_t malloc_usage (void);
+//void malloc_init (void);
+//void malloc_final (void);
+
+void malloc_defaults(void);
+
+struct malloc_interface {
+ void* (*malloc )(size_t size, const char *file, int line, const char *func);
+ void* (*calloc )(size_t num, size_t size, const char *file, int line, const char *func);
+ void* (*realloc )(void *p, size_t size, const char *file, int line, const char *func);
+ char* (*astrdup )(const char *p, const char *file, int line, const char *func);
+ void (*free )(void *p, const char *file, int line, const char *func);
+
+ void (*memory_check)(void);
+ bool (*verify_ptr)(void* ptr);
+ size_t (*usage) (void);
+ void (*init) (void);
+ void (*final) (void);
+} malloclib_s;
+
+struct malloc_interface *malloclib;
#endif /* _MALLOC_H_ */