Returning NULL from mem_heap_alloc_block if requested block size is zero.

This commit is contained in:
Ruben Ayrapetyan
2014-12-18 13:26:42 +03:00
parent 9b1fff1d8b
commit 1e0eea3d73
2 changed files with 18 additions and 7 deletions
+7 -2
View File
@@ -409,8 +409,8 @@ mem_init_block_header (uint8_t *first_chunk_p, /**< address of the first
* It is supposed, that all short-term allocation is used during relatively short discrete sessions.
* After end of the session all short-term allocated regions are supposed to be freed.
*
* @return pointer to allocated memory block - if allocation is successful,\n
* NULL - if there is not enough memory.
* @return pointer to allocated memory block - if allocation is successful,
* NULL - if requested region size is zero or if there is not enough memory.
*/
void*
mem_heap_alloc_block (size_t size_in_bytes, /**< size of region to allocate in bytes */
@@ -421,6 +421,11 @@ mem_heap_alloc_block (size_t size_in_bytes, /**< size of region to all
mem_check_heap ();
if (size_in_bytes == 0)
{
return NULL;
}
if (alloc_term == MEM_HEAP_ALLOC_LONG_TERM)
{
block_p = mem_heap.first_block_p;