2011-09-10 Ulrich Drepper <drepper@gmail.com>
+ * malloc/malloc.c: Replace MALLOC_FAILURE_ACTION with use of __set_errno.
+ * malloc/hooks.c: Likewise.
+
* malloc/arena.c (ptmalloc_init_minimal): Removed. Initialize all
variables statically.
(narenas): Initialize.
new_brk = (char*)(MORECORE (sbrk_size));
if (new_brk == (char*)(MORECORE_FAILURE))
{
- MALLOC_FAILURE_ACTION;
+ __set_errno (ENOMEM);
return -1;
}
/* Call the `morecore' hook if necessary. */
void *victim;
if (sz+1 == 0) {
- MALLOC_FAILURE_ACTION;
+ __set_errno (ENOMEM);
return NULL;
}
unsigned char *magic_p;
if (bytes+1 == 0) {
- MALLOC_FAILURE_ACTION;
+ __set_errno (ENOMEM);
return NULL;
}
if (oldmem == 0) return malloc_check(bytes, NULL);
if (alignment < MINSIZE) alignment = MINSIZE;
if (bytes+1 == 0) {
- MALLOC_FAILURE_ACTION;
+ __set_errno (ENOMEM);
return NULL;
}
(void)mutex_lock(&main_arena.mutex);
USE_MALLOC_LOCK NOT defined
MALLOC_DEBUG NOT defined
REALLOC_ZERO_BYTES_FREES 1
- MALLOC_FAILURE_ACTION errno = ENOMEM
TRIM_FASTBINS 0
Options for customizing MORECORE:
#include <unistd.h>
#include <stdio.h> /* needed for malloc_stats */
-#include <errno.h> /* needed for optional MALLOC_FAILURE_ACTION */
+#include <errno.h>
/* For uintptr_t. */
#include <stdint.h>
({ __typeof (val) _v; asm ("" : "=r" (_v) : "0" (val)); _v; })
-/*
- MALLOC_FAILURE_ACTION is the action to take before "return 0" when
- malloc fails to be able to return memory, either because memory is
- exhausted or because of illegal arguments.
-
- By default, sets errno if running on STD_C platform, else does nothing.
-*/
-
-#ifndef MALLOC_FAILURE_ACTION
-#define MALLOC_FAILURE_ACTION \
- errno = ENOMEM;
-
-#endif
-
/*
MORECORE-related declarations. By default, rely on sbrk
*/
#define checked_request2size(req, sz) \
if (REQUEST_OUT_OF_RANGE(req)) { \
- MALLOC_FAILURE_ACTION; \
+ __set_errno (ENOMEM); \
return 0; \
} \
(sz) = request2size(req);
}
/* catch all failure paths */
- MALLOC_FAILURE_ACTION;
+ __set_errno (ENOMEM);
return 0;
}
(((INTERNAL_SIZE_T) 1) << (8 * sizeof (INTERNAL_SIZE_T) / 2))
if (__builtin_expect ((n | elem_size) >= HALF_INTERNAL_SIZE_T, 0)) {
if (elem_size != 0 && bytes / elem_size != n) {
- MALLOC_FAILURE_ACTION;
+ __set_errno (ENOMEM);
return 0;
}
}