Simplify malloc_message().
Rather than passing four strings to malloc_message(), malloc_write4(), and all the functions that use them, only pass one string.
This commit is contained in:
@@ -75,17 +75,19 @@ bool ctl_boot(void);
|
||||
#define xmallctl(name, oldp, oldlenp, newp, newlen) do { \
|
||||
if (JEMALLOC_P(mallctl)(name, oldp, oldlenp, newp, newlen) \
|
||||
!= 0) { \
|
||||
malloc_write4("<jemalloc>: Invalid xmallctl(\"", name, \
|
||||
"\", ...) call\n", ""); \
|
||||
malloc_write("<jemalloc>: Invalid xmallctl(\""); \
|
||||
malloc_write(name); \
|
||||
malloc_write("\", ...) call\n"); \
|
||||
abort(); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define xmallctlnametomib(name, mibp, miblenp) do { \
|
||||
if (JEMALLOC_P(mallctlnametomib)(name, mibp, miblenp) != 0) { \
|
||||
malloc_write4( \
|
||||
"<jemalloc>: Invalid xmallctlnametomib(\"", name, \
|
||||
"\", ...) call\n", ""); \
|
||||
malloc_write( \
|
||||
"<jemalloc>: Invalid xmallctlnametomib(\""); \
|
||||
malloc_write(name); \
|
||||
malloc_write("\", ...) call\n"); \
|
||||
abort(); \
|
||||
} \
|
||||
} while (0)
|
||||
@@ -93,9 +95,8 @@ bool ctl_boot(void);
|
||||
#define xmallctlbymib(mib, miblen, oldp, oldlenp, newp, newlen) do { \
|
||||
if (JEMALLOC_P(mallctlbymib)(mib, miblen, oldp, oldlenp, newp, \
|
||||
newlen) != 0) { \
|
||||
malloc_write4( \
|
||||
"<jemalloc>: Invalid xmallctlbymib() call\n", "", \
|
||||
"", ""); \
|
||||
malloc_write( \
|
||||
"<jemalloc>: Invalid xmallctlbymib() call\n"); \
|
||||
abort(); \
|
||||
} \
|
||||
} while (0)
|
||||
|
@@ -36,8 +36,7 @@
|
||||
#include "jemalloc/internal/qr.h"
|
||||
#include "jemalloc/internal/ql.h"
|
||||
|
||||
extern void (*JEMALLOC_P(malloc_message))(void *w4opaque, const char *p1,
|
||||
const char *p2, const char *p3, const char *p4);
|
||||
extern void (*JEMALLOC_P(malloc_message))(void *wcbopaque, const char *s);
|
||||
|
||||
/*
|
||||
* Define a custom assert() in order to reduce the chances of deadlock during
|
||||
@@ -47,10 +46,14 @@ extern void (*JEMALLOC_P(malloc_message))(void *w4opaque, const char *p1,
|
||||
# define assert(e) do { \
|
||||
if (!(e)) { \
|
||||
char line_buf[UMAX2S_BUFSIZE]; \
|
||||
malloc_write4("<jemalloc>: ", __FILE__, ":", \
|
||||
umax2s(__LINE__, 10, line_buf)); \
|
||||
malloc_write4(": Failed assertion: ", "\"", #e, \
|
||||
"\"\n"); \
|
||||
malloc_write("<jemalloc>: "); \
|
||||
malloc_write(__FILE__); \
|
||||
malloc_write(":"); \
|
||||
malloc_write(umax2s(__LINE__, 10, line_buf)); \
|
||||
malloc_write(": Failed assertion: "); \
|
||||
malloc_write("\""); \
|
||||
malloc_write(#e); \
|
||||
malloc_write("\"\n"); \
|
||||
abort(); \
|
||||
} \
|
||||
} while (0)
|
||||
@@ -282,8 +285,7 @@ arena_t *choose_arena_hard(void);
|
||||
#include "jemalloc/internal/huge.h"
|
||||
|
||||
#ifndef JEMALLOC_ENABLE_INLINE
|
||||
void malloc_write4(const char *p1, const char *p2, const char *p3,
|
||||
const char *p4);
|
||||
void malloc_write(const char *s);
|
||||
arena_t *choose_arena(void);
|
||||
#endif
|
||||
|
||||
@@ -293,10 +295,10 @@ arena_t *choose_arena(void);
|
||||
* JEMALLOC_P(malloc_message)(...) throughout the code.
|
||||
*/
|
||||
JEMALLOC_INLINE void
|
||||
malloc_write4(const char *p1, const char *p2, const char *p3, const char *p4)
|
||||
malloc_write(const char *s)
|
||||
{
|
||||
|
||||
JEMALLOC_P(malloc_message)(NULL, p1, p2, p3, p4);
|
||||
JEMALLOC_P(malloc_message)(NULL, s);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -136,14 +136,13 @@ extern bool opt_stats_print;
|
||||
|
||||
char *umax2s(uintmax_t x, unsigned base, char *s);
|
||||
#ifdef JEMALLOC_STATS
|
||||
void malloc_cprintf(void (*write4)(void *, const char *, const char *,
|
||||
const char *, const char *), void *w4opaque, const char *format, ...)
|
||||
JEMALLOC_ATTR(format(printf, 3, 4));
|
||||
void malloc_cprintf(void (*write)(void *, const char *), void *cbopaque,
|
||||
const char *format, ...) JEMALLOC_ATTR(format(printf, 3, 4));
|
||||
void malloc_printf(const char *format, ...)
|
||||
JEMALLOC_ATTR(format(printf, 1, 2));
|
||||
#endif
|
||||
void stats_print(void (*write4)(void *, const char *, const char *,
|
||||
const char *, const char *), void *w4opaque, const char *opts);
|
||||
void stats_print(void (*write)(void *, const char *), void *cbopaque,
|
||||
const char *opts);
|
||||
|
||||
#endif /* JEMALLOC_H_EXTERNS */
|
||||
/******************************************************************************/
|
||||
|
@@ -17,8 +17,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
extern const char *JEMALLOC_P(malloc_options);
|
||||
extern void (*JEMALLOC_P(malloc_message))(void *, const char *p1,
|
||||
const char *p2, const char *p3, const char *p4);
|
||||
extern void (*JEMALLOC_P(malloc_message))(void *, const char *);
|
||||
|
||||
void *JEMALLOC_P(malloc)(size_t size) JEMALLOC_ATTR(malloc);
|
||||
void *JEMALLOC_P(calloc)(size_t num, size_t size) JEMALLOC_ATTR(malloc);
|
||||
@@ -28,9 +27,8 @@ void *JEMALLOC_P(realloc)(void *ptr, size_t size);
|
||||
void JEMALLOC_P(free)(void *ptr);
|
||||
|
||||
size_t JEMALLOC_P(malloc_usable_size)(const void *ptr);
|
||||
void JEMALLOC_P(malloc_stats_print)(void (*write4)(void *, const char *,
|
||||
const char *, const char *, const char *), void *w4opaque,
|
||||
const char *opts);
|
||||
void JEMALLOC_P(malloc_stats_print)(void (*write_cb)(void *, const char *),
|
||||
void *cbopaque, const char *opts);
|
||||
int JEMALLOC_P(mallctl)(const char *name, void *oldp, size_t *oldlenp,
|
||||
void *newp, size_t newlen);
|
||||
int JEMALLOC_P(mallctlnametomib)(const char *name, size_t *mibp,
|
||||
|
Reference in New Issue
Block a user