summaryrefslogtreecommitdiff
path: root/lib/memory.c
diff options
context:
space:
mode:
authorMitesh Kanjariya <mitesh@cumulusnetworks.com>2017-08-28 18:19:03 -0700
committerGitHub <noreply@github.com>2017-08-28 18:19:03 -0700
commit09fdc88c8cb0cd4169ae97b652d82f6a174a4041 (patch)
treece312038b12ce5128d375fa075c52ce30cf64207 /lib/memory.c
parent6b3ee3a0b013e580abbce83ae46e4ed2bcf5f7a7 (diff)
parent126ee21d2ed9451aefab869c482bb28c6b4f6085 (diff)
Merge branch 'master' into dev-master
Diffstat (limited to 'lib/memory.c')
-rw-r--r--lib/memory.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/memory.c b/lib/memory.c
index 0ccc204002..c684c7605c 100644
--- a/lib/memory.c
+++ b/lib/memory.c
@@ -104,6 +104,7 @@ int qmem_walk(qmem_walk_fn *func, void *arg)
}
struct exit_dump_args {
+ FILE *fp;
const char *prefix;
int error;
};
@@ -113,7 +114,7 @@ static int qmem_exit_walker(void *arg, struct memgroup *mg, struct memtype *mt)
struct exit_dump_args *eda = arg;
if (!mt) {
- fprintf(stderr,
+ fprintf(eda->fp,
"%s: showing active allocations in "
"memory group %s\n",
eda->prefix, mg->name);
@@ -122,15 +123,16 @@ static int qmem_exit_walker(void *arg, struct memgroup *mg, struct memtype *mt)
char size[32];
eda->error++;
snprintf(size, sizeof(size), "%10zu", mt->size);
- fprintf(stderr, "%s: memstats: %-30s: %6zu * %s\n",
+ fprintf(eda->fp, "%s: memstats: %-30s: %6zu * %s\n",
eda->prefix, mt->name, mt->n_alloc,
mt->size == SIZE_VAR ? "(variably sized)" : size);
}
return 0;
}
-void log_memstats_stderr(const char *prefix)
+int log_memstats(FILE *fp, const char *prefix)
{
- struct exit_dump_args eda = {.prefix = prefix, .error = 0};
+ struct exit_dump_args eda = { .fp = fp, .prefix = prefix, .error = 0 };
qmem_walk(qmem_exit_walker, &eda);
+ return eda.error;
}