version 1.22, 2011/02/26 23:27:49 |
version 1.28, 2012/03/21 14:32:22 |
Line 816 static void wrtmessage(const char *p1, c |
|
Line 816 static void wrtmessage(const char *p1, c |
|
#ifdef MALLOC_STATS |
#ifdef MALLOC_STATS |
static void malloc_printf(const char *format, ...); |
static void malloc_printf(const char *format, ...); |
#endif |
#endif |
static char *umax2s(uintmax_t x, char *s); |
static char *size_t2s(size_t x, char *s); |
static bool base_pages_alloc(size_t minsize); |
static bool base_pages_alloc(size_t minsize); |
static void *base_alloc(size_t size); |
static void *base_alloc(size_t size); |
static chunk_node_t *base_chunk_node_alloc(void); |
static chunk_node_t *base_chunk_node_alloc(void); |
Line 978 malloc_printf(const char *format, ...) |
|
Line 978 malloc_printf(const char *format, ...) |
|
|
|
/* |
/* |
* We don't want to depend on vsnprintf() for production builds, since that can |
* We don't want to depend on vsnprintf() for production builds, since that can |
* cause unnecessary bloat for static binaries. umax2s() provides minimal |
* cause unnecessary bloat for static binaries. size_t2s() provides minimal |
* integer printing functionality, so that malloc_printf() use can be limited to |
* integer printing functionality, so that malloc_printf() use can be limited to |
* MALLOC_STATS code. |
* MALLOC_STATS code. |
*/ |
*/ |
#define UMAX2S_BUFSIZE 21 |
#define UMAX2S_BUFSIZE 21 |
static char * |
static char * |
umax2s(uintmax_t x, char *s) |
size_t2s(size_t x, char *s) |
{ |
{ |
unsigned i; |
unsigned i; |
|
|
/* Make sure UMAX2S_BUFSIZE is large enough. */ |
/* Make sure UMAX2S_BUFSIZE is large enough. */ |
/* LINTED */ |
/* LINTED */ |
assert(sizeof(uintmax_t) <= 8); |
assert(sizeof(size_t) <= 8); |
|
|
i = UMAX2S_BUFSIZE - 1; |
i = UMAX2S_BUFSIZE - 1; |
s[i] = '\0'; |
s[i] = '\0'; |
Line 3218 malloc_print_stats(void) |
|
Line 3218 malloc_print_stats(void) |
|
opt_xmalloc ? "X" : "x", |
opt_xmalloc ? "X" : "x", |
opt_zero ? "Z\n" : "z\n"); |
opt_zero ? "Z\n" : "z\n"); |
|
|
_malloc_message("CPUs: ", umax2s(ncpus, s), "\n", ""); |
_malloc_message("CPUs: ", size_t2s(ncpus, s), "\n", ""); |
_malloc_message("Max arenas: ", umax2s(narenas, s), "\n", ""); |
_malloc_message("Max arenas: ", size_t2s(narenas, s), "\n", ""); |
_malloc_message("Pointer size: ", umax2s(sizeof(void *), s), |
_malloc_message("Pointer size: ", size_t2s(sizeof(void *), s), |
"\n", ""); |
"\n", ""); |
_malloc_message("Quantum size: ", umax2s(quantum, s), "\n", ""); |
_malloc_message("Quantum size: ", size_t2s(quantum, s), "\n", ""); |
_malloc_message("Max small size: ", umax2s(small_max, s), "\n", |
_malloc_message("Max small size: ", size_t2s(small_max, s), "\n", |
""); |
""); |
|
|
_malloc_message("Chunk size: ", umax2s(chunksize, s), "", ""); |
_malloc_message("Chunk size: ", size_t2s(chunksize, s), "", ""); |
_malloc_message(" (2^", umax2s(opt_chunk_2pow, s), ")\n", ""); |
_malloc_message(" (2^", size_t2s((size_t)opt_chunk_2pow, s), |
|
")\n", ""); |
|
|
#ifdef MALLOC_STATS |
#ifdef MALLOC_STATS |
{ |
{ |
Line 3325 malloc_init_hard(void) |
|
Line 3326 malloc_init_hard(void) |
|
ssize_t linklen; |
ssize_t linklen; |
char buf[PATH_MAX + 1]; |
char buf[PATH_MAX + 1]; |
const char *opts = ""; |
const char *opts = ""; |
|
int serrno; |
|
|
malloc_mutex_lock(&init_lock); |
malloc_mutex_lock(&init_lock); |
if (malloc_initialized) { |
if (malloc_initialized) { |
Line 3336 malloc_init_hard(void) |
|
Line 3338 malloc_init_hard(void) |
|
return (false); |
return (false); |
} |
} |
|
|
|
serrno = errno; |
/* Get number of CPUs. */ |
/* Get number of CPUs. */ |
{ |
{ |
int mib[2]; |
int mib[2]; |
Line 3515 malloc_init_hard(void) |
|
Line 3518 malloc_init_hard(void) |
|
} |
} |
} |
} |
} |
} |
|
errno = serrno; |
|
|
/* Take care to call atexit() only once. */ |
/* Take care to call atexit() only once. */ |
if (opt_print_stats) { |
if (opt_print_stats) { |