From 25e848f1a0f9317d63106cae048a1ef838411cb2 Mon Sep 17 00:00:00 2001 From: Susu Date: Fri, 17 May 2013 11:10:30 +0200 Subject: - Made DB and malloc lib HPM-friendly - Also fixed a bug preventing the plugins to be loeaded because HPMI and HPMI_s weren't HPExport --- src/common/malloc.h | 72 ++++++++++++++++++++++++----------------------------- 1 file changed, 32 insertions(+), 40 deletions(-) (limited to 'src/common/malloc.h') diff --git a/src/common/malloc.h b/src/common/malloc.h index 6b4e8e5c4..2e745481f 100644 --- a/src/common/malloc.h +++ b/src/common/malloc.h @@ -22,9 +22,6 @@ ////////////////////////////////////////////////////////////////////// -// Athena's built-in Memory Manager -#ifdef USE_MEMMGR - // Enable memory manager logging by default #define LOG_MEMMGR @@ -33,46 +30,24 @@ #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->strdup (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* (*strdup )(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_ */ -- cgit v1.2.3-70-g09d2 From 105101af513e24c2d2ff113f5d9b1aaab1326255 Mon Sep 17 00:00:00 2001 From: shennetsind Date: Fri, 17 May 2013 15:39:13 -0300 Subject: Travis Fix Attempt #1 Signed-off-by: shennetsind --- src/common/malloc.c | 4 ++-- src/common/malloc.h | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/common/malloc.h') diff --git a/src/common/malloc.c b/src/common/malloc.c index 77eef2508..4874aa0f4 100644 --- a/src/common/malloc.c +++ b/src/common/malloc.c @@ -734,13 +734,13 @@ void malloc_defaults() malloclib->malloc = _mmalloc; malloclib->calloc = _mcalloc; malloclib->realloc = _mrealloc; - malloclib->strdup = _mstrdup; + malloclib->astrdup = _mstrdup; malloclib->free = _mfree; #else malloclib->malloc = aMalloc_; malloclib->calloc = aCalloc_; malloclib->realloc = aRealloc_; - malloclib->strdup = aStrdup_; + malloclib->astrdup = aStrdup_; malloclib->free = aFree_; #endif } diff --git a/src/common/malloc.h b/src/common/malloc.h index 2e745481f..c0b1fda84 100644 --- a/src/common/malloc.h +++ b/src/common/malloc.h @@ -27,13 +27,13 @@ // no logging for minicore #if defined(MINICORE) && defined(LOG_MEMMGR) -#undef LOG_MEMMGR + #undef LOG_MEMMGR #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->strdup (p,ALC_MARK) +# define aStrdup(p) malloclib->astrdup (p,ALC_MARK) # define aFree(p) malloclib->free (p,ALC_MARK) /////////////// Buffer Creation ///////////////// @@ -70,7 +70,7 @@ 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* (*strdup )(const char *p, 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); -- cgit v1.2.3-70-g09d2 From b0f866ca419d87fcb3625b45e2437e0a0bb1810e Mon Sep 17 00:00:00 2001 From: shennetsind Date: Fri, 17 May 2013 15:43:04 -0300 Subject: Travis Trigger Test #2 Signed-off-by: shennetsind --- src/common/malloc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/common/malloc.h') diff --git a/src/common/malloc.h b/src/common/malloc.h index c0b1fda84..34a26b56e 100644 --- a/src/common/malloc.h +++ b/src/common/malloc.h @@ -71,7 +71,7 @@ struct malloc_interface { 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 (*free )(void *p, const char *file, int line, const char *func); void (*memory_check)(void); bool (*verify_ptr)(void* ptr); -- cgit v1.2.3-70-g09d2