mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-05-26 23:06:30 +03:00
Safety checks: Add a redzoning feature.
This commit is contained in:
parent
b92c9a1a81
commit
33e1dad680
12 changed files with 233 additions and 22 deletions
|
|
@ -1,11 +1,24 @@
|
|||
#include "jemalloc/internal/jemalloc_preamble.h"
|
||||
#include "jemalloc/internal/jemalloc_internal_includes.h"
|
||||
|
||||
void safety_check_fail(const char *format, ...) {
|
||||
va_list ap;
|
||||
static void (*safety_check_abort)(const char *message);
|
||||
|
||||
va_start(ap, format);
|
||||
malloc_vcprintf(NULL, NULL, format, ap);
|
||||
va_end(ap);
|
||||
abort();
|
||||
void safety_check_set_abort(void (*abort_fn)(const char *)) {
|
||||
safety_check_abort = abort_fn;
|
||||
}
|
||||
|
||||
void safety_check_fail(const char *format, ...) {
|
||||
char buf[MALLOC_PRINTF_BUFSIZE];
|
||||
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
malloc_vsnprintf(buf, MALLOC_PRINTF_BUFSIZE, format, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (safety_check_abort == NULL) {
|
||||
malloc_write(buf);
|
||||
abort();
|
||||
} else {
|
||||
safety_check_abort(buf);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue