
shejo284 at gmail
Nov 17, 2006, 6:14 AM
Post #1 of 3
(126 views)
Permalink
|
|
function for allocating memory for string array
|
|
Hi, Can someone tell me how to remove the conflicts here ? #include <stdlib> static char*** Memory2DStr(int R, int C); static void MemoryFreeStr(int C, char*** array); void main() { unsigned char ***arr_scenes=NULL; int R = 15; int C = 15; arr_scenes = Memory2DStr(nscenes,2); MemoryFreeStr(2,arr_scenes); } static char*** Memory2DStr(int R, int C) { char*** array; int i; array = calloc(C,sizeof(char **)); if(array == NULL) { fprintf(stderr, "Failed to allocate memory\n"); exit(EXIT_FAILURE); } for (i = 0; i < C; i++) { array[i] = calloc(R,sizeof(char*)); if(array == NULL) { // Memory for the Col fprintf(stderr, "Failed to allocate memory\n"); exit(EXIT_FAILURE); } } return array; } static void MemoryFreeStr(int Col, char*** array) { int i; for (i = 0; i < 15; i++) { free((*array)[i]); } free(*array); } Thanks, Sheldon -- http://mail.python.org/mailman/listinfo/python-list
|