diff options
Diffstat (limited to 'deps/jemalloc/src/util.c')
-rw-r--r--[-rwxr-xr-x] | deps/jemalloc/src/util.c | 42 |
1 files changed, 13 insertions, 29 deletions
diff --git a/deps/jemalloc/src/util.c b/deps/jemalloc/src/util.c index dd8c23630..4cb0d6c1e 100755..100644 --- a/deps/jemalloc/src/util.c +++ b/deps/jemalloc/src/util.c @@ -1,7 +1,3 @@ -/* - * Define simple versions of assertion macros that won't recurse in case - * of assertion failures in malloc_*printf(). - */ #define assert(e) do { \ if (config_debug && !(e)) { \ malloc_write("<jemalloc>: Failed assertion\n"); \ @@ -14,7 +10,6 @@ malloc_write("<jemalloc>: Unreachable code reached\n"); \ abort(); \ } \ - unreachable(); \ } while (0) #define not_implemented() do { \ @@ -49,19 +44,15 @@ static void wrtmessage(void *cbopaque, const char *s) { -#if defined(JEMALLOC_USE_SYSCALL) && defined(SYS_write) +#ifdef SYS_write /* * Use syscall(2) rather than write(2) when possible in order to avoid * the possibility of memory allocation within libc. This is necessary * on FreeBSD; most operating systems do not have this problem though. - * - * syscall() returns long or int, depending on platform, so capture the - * unused result in the widest plausible type to avoid compiler - * warnings. */ - UNUSED long result = syscall(SYS_write, STDERR_FILENO, s, strlen(s)); + UNUSED int result = syscall(SYS_write, STDERR_FILENO, s, strlen(s)); #else - UNUSED ssize_t result = write(STDERR_FILENO, s, strlen(s)); + UNUSED int result = write(STDERR_FILENO, s, strlen(s)); #endif } @@ -91,7 +82,7 @@ buferror(int err, char *buf, size_t buflen) #ifdef _WIN32 FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, 0, - (LPSTR)buf, (DWORD)buflen, NULL); + (LPSTR)buf, buflen, NULL); return (0); #elif defined(__GLIBC__) && defined(_GNU_SOURCE) char *b = strerror_r(err, buf, buflen); @@ -200,7 +191,7 @@ malloc_strtoumax(const char *restrict nptr, char **restrict endptr, int base) p++; } if (neg) - ret = (uintmax_t)(-((intmax_t)ret)); + ret = -ret; if (p == ns) { /* No conversion performed. */ @@ -315,9 +306,10 @@ x2s(uintmax_t x, bool alt_form, bool uppercase, char *s, size_t *slen_p) return (s); } -size_t +int malloc_vsnprintf(char *str, size_t size, const char *format, va_list ap) { + int ret; size_t i; const char *f; @@ -408,8 +400,6 @@ malloc_vsnprintf(char *str, size_t size, const char *format, va_list ap) int prec = -1; int width = -1; unsigned char len = '?'; - char *s; - size_t slen; f++; /* Flags. */ @@ -500,6 +490,8 @@ malloc_vsnprintf(char *str, size_t size, const char *format, va_list ap) } /* Conversion specifier. */ switch (*f) { + char *s; + size_t slen; case '%': /* %% */ APPEND_C(*f); @@ -585,19 +577,20 @@ malloc_vsnprintf(char *str, size_t size, const char *format, va_list ap) str[i] = '\0'; else str[size - 1] = '\0'; + ret = i; #undef APPEND_C #undef APPEND_S #undef APPEND_PADDED_S #undef GET_ARG_NUMERIC - return (i); + return (ret); } JEMALLOC_FORMAT_PRINTF(3, 4) -size_t +int malloc_snprintf(char *str, size_t size, const char *format, ...) { - size_t ret; + int ret; va_list ap; va_start(ap, format); @@ -655,12 +648,3 @@ malloc_printf(const char *format, ...) malloc_vcprintf(NULL, NULL, format, ap); va_end(ap); } - -/* - * Restore normal assertion macros, in order to make it possible to compile all - * C files as a single concatenation. - */ -#undef assert -#undef not_reached -#undef not_implemented -#include "jemalloc/internal/assert.h" |