Skip to content
Snippets Groups Projects
Commit 38dae136 authored by Kostyantyn Vorobyov's avatar Kostyantyn Vorobyov
Browse files

[ADT RTL] Fixed a bug that caused memory blocks allocated via calloc

appear as uninitialized data
parent 5ff63151
No related branches found
No related tags found
No related merge requests found
......@@ -195,16 +195,19 @@ void* __realloc(void* ptr, size_t size) {
* for further information, see calloc */
void* __calloc(size_t nbr_block, size_t size_block) {
void * tmp;
size_t size = nbr_block * size_block;
struct _block * new_block;
if(nbr_block * size_block <= 0)
if(size <= 0)
return NULL;
tmp = native_calloc(nbr_block, size_block);
if(tmp == NULL)
return NULL;
new_block = __store_block(tmp, nbr_block * size_block);
new_block = __store_block(tmp, size);
__heap_size += nbr_block * size_block;
DASSERT(new_block != NULL && (void*)new_block->ptr != NULL);
/* Mark allocated block as freeable and initialized */
new_block->freeable = true;
new_block->init_cpt = size;
return (void*)new_block->ptr;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment