mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[liba] Abort if malloc does not return a defined pointer
Change-Id: I732bc5ca4eba23905bdb8cf49cbf70941ed97068
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <private/memconfig.h>
|
||||
|
||||
#if LIBA_LOG_DYNAMIC_MEMORY
|
||||
@@ -55,6 +56,11 @@ void * malloc(size_t size) {
|
||||
ion_log_print_integer((uint32_t)size);
|
||||
ion_log_print_string("\n");
|
||||
#endif
|
||||
/* If the process could not find enough space in the memory dedicated to
|
||||
* dynamic allocation, p is NULL. The conventional malloc just return NULL
|
||||
* without crashing. However, for debuging purposes, we abort the process
|
||||
* in that case to easily spot memory leaking. */
|
||||
assert(p != NULL);
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user