Returning NULL from mem_heap_alloc_block if requested block size is zero.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user