I'm using the MCBx51 V2.1 prototype Board with the Keil uVision2 software, but I have some problems with memory allocation. This is the code that i had typed. p = malloc (1000); if (p == NULL) printf ("Not enough memory space\n"); else printf ("Memory allocated\n"); p[0] = 0x01; p[1] = 0x03; printf("%c",p[0]); printf("%c",p[1]); How come the output from the serial port is 0x0100 instead of 0x0103? Can anyone help me... Thanks...
int SIZE=1; p = (char*) malloc( SIZE ); if (p == NULL) printf ("Not enough memory space\n"); else printf ("Memory allocated\n"); This is a script that i wrote to check if there is any memory allocated for the variable 'p'. To my surprise, no matter what amount i decleare SIZE as, ranging from 1 to 1000, it keeps printing "Not enough memory space". What is the problem??
have you called the 'initmempool' (or whatever it's called) before calling malloc?