From 6e71a3c9eeb838a79d82b19137f1c11b0e58c974 Mon Sep 17 00:00:00 2001 From: lloyd Date: Sun, 26 Sep 2010 17:07:21 +0000 Subject: Malloc_Allocator isn't a pool, so it needs to fail directly if malloc fails, not just return 0 since callers expect that the allocator will either succeed or throw. --- src/alloc/system_alloc/defalloc.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/alloc') diff --git a/src/alloc/system_alloc/defalloc.cpp b/src/alloc/system_alloc/defalloc.cpp index 311057462..596deb3d0 100644 --- a/src/alloc/system_alloc/defalloc.cpp +++ b/src/alloc/system_alloc/defalloc.cpp @@ -54,7 +54,9 @@ void do_free(void* ptr, u32bit n, bool do_lock) */ void* Malloc_Allocator::allocate(u32bit n) { - return do_malloc(n, false); + void* ptr = do_malloc(n, false); + if(!ptr) + throw Memory_Exhaustion(); } /* -- cgit v1.2.3