-
-
Notifications
You must be signed in to change notification settings - Fork 81
Open
Description
malloc() does not always work as expected:
// example by MSDev from support discord channel
u16 c = 12;
u16 d = 15;
char cArray[3];
char *dCharPtr = (char*) malloc(sizeof(char)*3);
sprintf(cArray,"%d",c);
sprintf(dCharPtr, "%d", d);
consoleNocashMessage("cArray=%s\n", cArray);
consoleNocashMessage("dCharPtr=%s\n", dCharPtr);
Output should be:
cArray=12
dCharPtr=15
Output is:
cArray=12
dCharPtr=<NULL>
I noticed that you get correct results, if your project is big enough: If .obj files are larger than 35 KB, malloc() works as expected.
This example is big enough: https://github.com/alekmaul/pvsneslib/tree/master/snes-examples/maps/mapbuffer
Metadata
Metadata
Assignees
Labels
No labels