summaryrefslogtreecommitdiff
path: root/src/common/malloc.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/malloc.h')
-rw-r--r--src/common/malloc.h35
1 files changed, 20 insertions, 15 deletions
diff --git a/src/common/malloc.h b/src/common/malloc.h
index 834781905..8dace2d68 100644
--- a/src/common/malloc.h
+++ b/src/common/malloc.h
@@ -1,8 +1,8 @@
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
// For more information, see LICENCE in the main folder
-#ifndef _MALLOC_H_
-#define _MALLOC_H_
+#ifndef COMMON_MALLOC_H
+#define COMMON_MALLOC_H
#include "../common/cbasetypes.h"
@@ -30,11 +30,12 @@
#undef LOG_MEMMGR
#endif
-# define aMalloc(n) iMalloc->malloc (n,ALC_MARK)
-# define aCalloc(m,n) iMalloc->calloc (m,n,ALC_MARK)
-# define aRealloc(p,n) iMalloc->realloc (p,n,ALC_MARK)
-# define aStrdup(p) iMalloc->astrdup (p,ALC_MARK)
-# define aFree(p) iMalloc->free (p,ALC_MARK)
+# define aMalloc(n) (iMalloc->malloc((n),ALC_MARK))
+# define aCalloc(m,n) (iMalloc->calloc((m),(n),ALC_MARK))
+# define aRealloc(p,n) (iMalloc->realloc((p),(n),ALC_MARK))
+# define aReallocz(p,n) (iMalloc->reallocz((p),(n),ALC_MARK))
+# define aStrdup(p) (iMalloc->astrdup((p),ALC_MARK))
+# define aFree(p) (iMalloc->free((p),ALC_MARK))
/////////////// Buffer Creation /////////////////
// Full credit for this goes to Shinomori [Ajarn]
@@ -46,15 +47,15 @@
#else // others don't, so we emulate them
-#define CREATE_BUFFER(name, type, size) type *name = (type *) aCalloc (size, sizeof(type))
+#define CREATE_BUFFER(name, type, size) type *name = (type *) aCalloc((size), sizeof(type))
#define DELETE_BUFFER(name) aFree(name)
#endif
////////////// Others //////////////////////////
// should be merged with any of above later
-#define CREATE(result, type, number) (result) = (type *) aCalloc ((number), sizeof(type))
-#define RECREATE(result, type, number) (result) = (type *) aRealloc ((result), sizeof(type) * (number))
+#define CREATE(result, type, number) ((result) = (type *) aCalloc((number), sizeof(type)))
+#define RECREATE(result, type, number) ((result) = (type *) aReallocz((result), sizeof(type) * (number)))
////////////////////////////////////////////////
@@ -67,20 +68,24 @@
void malloc_defaults(void);
struct malloc_interface {
+ void (*init) (void);
+ void (*final) (void);
+ /* */
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);
+ void* (*reallocz)(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);
-} iMalloc_s;
+ /* */
+ void (*post_shutdown) (void);
+};
void memmgr_report (int extra);
struct malloc_interface *iMalloc;
-#endif /* _MALLOC_H_ */
+#endif /* COMMON_MALLOC_H */