Check for oom in a few more places

This commit is contained in:
Jesse Jones 2012-12-11 19:20:39 -08:00 committed by Brian Anderson
parent 0402360abb
commit 81805e0568
1 changed files with 8 additions and 0 deletions

View File

@ -87,6 +87,10 @@ memory_region::realloc(void *mem, size_t orig_size) {
size_t size = orig_size + HEADER_SIZE;
alloc_header *newMem = (alloc_header *)::realloc(alloc, size);
if (newMem == NULL) {
fprintf(stderr, "memory_region::realloc> Out of memory allocating %ld bytes", size);
abort();
}
# if RUSTRT_TRACK_ALLOCATIONS >= 1
assert(newMem->magic == MAGIC);
@ -118,6 +122,10 @@ memory_region::malloc(size_t size, const char *tag, bool zero) {
size_t old_size = size;
size += HEADER_SIZE;
alloc_header *mem = (alloc_header *)::malloc(size);
if (mem == NULL) {
fprintf(stderr, "memory_region::malloc> Out of memory allocating %ld bytes", size);
abort();
}
# if RUSTRT_TRACK_ALLOCATIONS >= 1
mem->magic = MAGIC;