Browse Source

add a helper function to print all pools #ifdef MALLOC_STATS

from David CARLIER
OPENBSD_6_1
otto 7 years ago
parent
commit
c662774838
1 changed files with 16 additions and 1 deletions
  1. +16
    -1
      src/lib/libc/stdlib/malloc.c

+ 16
- 1
src/lib/libc/stdlib/malloc.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: malloc.c,v 1.216 2017/03/24 16:15:31 otto Exp $ */
/* $OpenBSD: malloc.c,v 1.217 2017/03/24 16:23:05 otto Exp $ */
/*
* Copyright (c) 2008, 2010, 2011, 2016 Otto Moerbeek <otto@drijf.net>
* Copyright (c) 2012 Matthew Dempsky <matthew@openbsd.org>
@ -211,6 +211,8 @@ static void fill_canary(char *ptr, size_t sz, size_t allocated);
#ifdef MALLOC_STATS
void malloc_dump(int, int, struct dir_info *);
PROTO_NORMAL(malloc_dump);
void malloc_gdump(int);
PROTO_NORMAL(malloc_gdump);
static void malloc_exit(void);
#define CALLER __builtin_return_address(0)
#else
@ -2244,6 +2246,19 @@ malloc_dump(int fd, int poolno, struct dir_info *pool)
}
DEF_WEAK(malloc_dump);
void
malloc_gdump(int fd)
{
int i;
int saved_errno = errno;
for (i = 0; i < _MALLOC_MUTEXES; i++)
malloc_dump(fd, i, mopts.malloc_pool[i]);
errno = saved_errno;
}
DEF_WEAK(malloc_gdump);
static void
malloc_exit(void)
{


Loading…
Cancel
Save