Commit 1a8010cf authored by Julien Signoles's avatar Julien Signoles
Browse files

[runtime] fix pre-invokation of calloc (as for malloc in a previous commit)

parent bedbdcbe
......@@ -894,11 +894,16 @@ extern int MSPACES_INIT;
* behaviour is as if the size were some non-zero value, except that the
* returned pointer shall not be used to access an object." */
void* malloc(size_t size) {
mspaces_init();
size_t alloc_size = ALLOC_SIZE(size);
/* Return NULL if the size is too large to be aligned */
char* res = alloc_size ? (char*)public_malloc(alloc_size) : NULL;
char* res;
if (alloc_size) {
mspaces_init();
res = (char*)public_malloc(alloc_size);
} else
res = NULL;
if (res) {
/* Make sure there is sufficient room in shadow */
......@@ -920,8 +925,12 @@ void* calloc(size_t nmemb, size_t size) {
/* Since aligned size is required by the model do the allocation through
* `malloc` and nullify the memory space by hand */
char* res =
size ? (char*)public_malloc(alloc_size) : NULL;
char* res;
if (size) {
mspaces_init();
res = (char*)public_malloc(alloc_size);
} else
res = NULL;
if (res) {
/* Make sure there is sufficient room in shadow */
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment