malloc(0) is implementation-dependant, we return NULL.

This commit is contained in:
Enrico Fraccaroli (Galfurian)
2024-02-29 11:16:29 -05:00
parent f088eb4058
commit 670320df13
+3 -1
View File
@@ -41,7 +41,9 @@ static inline malloc_header_t *ptr_to_malloc_header(void *ptr)
void *malloc(unsigned int size)
{
assert(size && "Zero size requested.");
if (size == 0) {
return NULL;
}
size_t *ptr;
// Compute the real size we need to allocate.
size_t real_size = size + sizeof(malloc_header_t);