Deleted Added
full compact
util.c (286866) util.c (296221)
1/*
2 * Define simple versions of assertion macros that won't recurse in case
3 * of assertion failures in malloc_*printf().
4 */
1#define assert(e) do { \
2 if (config_debug && !(e)) { \
3 malloc_write("<jemalloc>: Failed assertion\n"); \
4 abort(); \
5 } \
6} while (0)
7
8#define not_reached() do { \

--- 35 unchanged lines hidden (view full) ---

44wrtmessage(void *cbopaque, const char *s)
45{
46
47#ifdef SYS_write
48 /*
49 * Use syscall(2) rather than write(2) when possible in order to avoid
50 * the possibility of memory allocation within libc. This is necessary
51 * on FreeBSD; most operating systems do not have this problem though.
5#define assert(e) do { \
6 if (config_debug && !(e)) { \
7 malloc_write("<jemalloc>: Failed assertion\n"); \
8 abort(); \
9 } \
10} while (0)
11
12#define not_reached() do { \

--- 35 unchanged lines hidden (view full) ---

48wrtmessage(void *cbopaque, const char *s)
49{
50
51#ifdef SYS_write
52 /*
53 * Use syscall(2) rather than write(2) when possible in order to avoid
54 * the possibility of memory allocation within libc. This is necessary
55 * on FreeBSD; most operating systems do not have this problem though.
56 *
57 * syscall() returns long or int, depending on platform, so capture the
58 * unused result in the widest plausible type to avoid compiler
59 * warnings.
52 */
60 */
53 UNUSED int result = syscall(SYS_write, STDERR_FILENO, s, strlen(s));
61 UNUSED long result = syscall(SYS_write, STDERR_FILENO, s, strlen(s));
54#else
62#else
55 UNUSED int result = write(STDERR_FILENO, s, strlen(s));
63 UNUSED ssize_t result = write(STDERR_FILENO, s, strlen(s));
56#endif
57}
58
59JEMALLOC_EXPORT void (*je_malloc_message)(void *, const char *s);
60
61JEMALLOC_ATTR(visibility("hidden"))
62void
63wrtmessage_1_0(const char *s1, const char *s2, const char *s3,

--- 29 unchanged lines hidden (view full) ---

93 * provide a wrapper.
94 */
95int
96buferror(int err, char *buf, size_t buflen)
97{
98
99#ifdef _WIN32
100 FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, 0,
64#endif
65}
66
67JEMALLOC_EXPORT void (*je_malloc_message)(void *, const char *s);
68
69JEMALLOC_ATTR(visibility("hidden"))
70void
71wrtmessage_1_0(const char *s1, const char *s2, const char *s3,

--- 29 unchanged lines hidden (view full) ---

101 * provide a wrapper.
102 */
103int
104buferror(int err, char *buf, size_t buflen)
105{
106
107#ifdef _WIN32
108 FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, 0,
101 (LPSTR)buf, buflen, NULL);
109 (LPSTR)buf, (DWORD)buflen, NULL);
102 return (0);
103#elif defined(__GLIBC__) && defined(_GNU_SOURCE)
104 char *b = strerror_r(err, buf, buflen);
105 if (b != buf) {
106 strncpy(buf, b, buflen);
107 buf[buflen-1] = '\0';
108 }
109 return (0);

--- 478 unchanged lines hidden (view full) ---

588 break;
589 }}
590 }
591 label_out:
592 if (i < size)
593 str[i] = '\0';
594 else
595 str[size - 1] = '\0';
110 return (0);
111#elif defined(__GLIBC__) && defined(_GNU_SOURCE)
112 char *b = strerror_r(err, buf, buflen);
113 if (b != buf) {
114 strncpy(buf, b, buflen);
115 buf[buflen-1] = '\0';
116 }
117 return (0);

--- 478 unchanged lines hidden (view full) ---

596 break;
597 }}
598 }
599 label_out:
600 if (i < size)
601 str[i] = '\0';
602 else
603 str[size - 1] = '\0';
596 ret = i;
604 assert(i < INT_MAX);
605 ret = (int)i;
597
598#undef APPEND_C
599#undef APPEND_S
600#undef APPEND_PADDED_S
601#undef GET_ARG_NUMERIC
602 return (ret);
603}
604

--- 54 unchanged lines hidden (view full) ---

659malloc_printf(const char *format, ...)
660{
661 va_list ap;
662
663 va_start(ap, format);
664 malloc_vcprintf(NULL, NULL, format, ap);
665 va_end(ap);
666}
606
607#undef APPEND_C
608#undef APPEND_S
609#undef APPEND_PADDED_S
610#undef GET_ARG_NUMERIC
611 return (ret);
612}
613

--- 54 unchanged lines hidden (view full) ---

668malloc_printf(const char *format, ...)
669{
670 va_list ap;
671
672 va_start(ap, format);
673 malloc_vcprintf(NULL, NULL, format, ap);
674 va_end(ap);
675}
676
677/*
678 * Restore normal assertion macros, in order to make it possible to compile all
679 * C files as a single concatenation.
680 */
681#undef assert
682#undef not_reached
683#undef not_implemented
684#include "jemalloc/internal/assert.h"