Hi! I have a big problem with dynamic allocation...
Here is the code:
1 2 3 4 5 6
| int i, j; unsigned char ** map = malloc(MAP_Y * sizeof(unsigned char)); for (i = 0; i < MAP_Y; i++) { map[i] = malloc(MAP_X * sizeof(unsigned char)); } |
and at the end :
1 2 3 4 5
| for (i = 0; i < MAP_Y ; i++) { free(map[i]); } free(map); |
When i start the program, the Ti89 display
BUSY icon and freeze but when i add
ngetchx(); in this part of code:
1 2 3 4 5 6 7 8
| int i, j; unsigned char ** map = malloc(MAP_Y * sizeof(unsigned char)); for (i = 0; i < MAP_Y; i++) { printf("%d",i); ngetchx(); //Here map[i] = malloc(MAP_X * sizeof(unsigned char)); } |
The 89 don't freeze and the program start but when i stop the program and i go to Var-Link menu, my asm program is now and expression (64000bytes).
I'm lost