summaryrefslogtreecommitdiff
path: root/astmm.c
diff options
context:
space:
mode:
authorMark Spencer <markster@digium.com>2003-05-08 18:51:06 +0000
committerMark Spencer <markster@digium.com>2003-05-08 18:51:06 +0000
commit5e26db0a5dfec439a12b0c01c2f170537e845af2 (patch)
tree536a3ecf0ba8187af4e1de2b120635db26b23df2 /astmm.c
parent94c3b352710cad5e8ae4b7bda52b52d31e09e4c6 (diff)
Add astmm
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@982 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'astmm.c')
-rwxr-xr-xastmm.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/astmm.c b/astmm.c
index 49cb3bbc4..34ec84232 100755
--- a/astmm.c
+++ b/astmm.c
@@ -80,8 +80,10 @@ static inline void *__ast_alloc_region(size_t size, int which, const char *file,
pthread_mutex_unlock(&reglock);
if (!reg) {
fprintf(stderr, "Out of memory :(\n");
- if (mmlog)
- fprintf(stderr, "%ld - Out of memory\n", time(NULL));
+ if (mmlog) {
+ fprintf(mmlog, "%ld - Out of memory\n", time(NULL));
+ fflush(mmlog);
+ }
}
return ptr;
}
@@ -129,9 +131,11 @@ static void __ast_free_region(void *ptr, const char *file, int lineno, const cha
} else {
fprintf(stderr, "WARNING: Freeing unused memory at %p, in %s of %s, line %d\n",
ptr, func, file, lineno);
- if (mmlog)
+ if (mmlog) {
fprintf(mmlog, "%ld - WARNING: Freeing unused memory at %p, in %s of %s, line %d\n", time(NULL),
ptr, func, file, lineno);
+ fflush(mmlog);
+ }
}
}
@@ -163,9 +167,11 @@ void *__ast_realloc(void *ptr, size_t size, const char *file, int lineno, const
if (!len) {
fprintf(stderr, "WARNING: Realloc of unalloced memory at %p, in %s of %s, line %d\n",
ptr, func, file, lineno);
- if (mmlog)
+ if (mmlog) {
fprintf(mmlog, "%ld - WARNING: Realloc of unalloced memory at %p, in %s of %s, line %d\n",
time(NULL), ptr, func, file, lineno);
+ fflush(mmlog);
+ }
return NULL;
}
}
@@ -331,8 +337,10 @@ void __ast_mm_init(void)
mmlog = fopen("/var/log/asterisk/mmlog", "a+");
if (option_verbose)
ast_verbose("Asterisk Malloc Debugger Started (see /var/log/mmlog)\n");
- if (mmlog)
+ if (mmlog) {
fprintf(mmlog, "%ld - New session\n", time(NULL));
+ fflush(mmlog);
+ }
}
#endif