#define UTIL_UTIL_SOURCE_C_C #include "util-util.h" void Swap(int *a, int *b) { int temp; temp = *a; *a = *b; *b = temp; } void **Allocate_Array(int row, int column) { int i; int k; void **dataptr; dataptr = (void **) calloc((size_t) (row), sizeof(char *)); if (!dataptr) { printf("\n Error: can't make 2-d array.") ; return(NULL); } /* Allocating memeory for scanptr */ for (i = 0; i < row; i++) { /* allocate memory for scanline */ dataptr[i] = (char *) calloc((size_t) (column), sizeof(char)); /*Initialize the Data Buffer */ if (!dataptr[i]) { printf(" Error : can't make row %d in [%dx%d] matrix.\n", i,row,column); exit(-1); } } return dataptr; } void ***Allocate_Array3D(int row1, int row2, int column) { int i; int k; void ***dataptr; dataptr = (void ***) calloc((size_t) (row1), sizeof(char **)); if (!dataptr) { printf("\n Error: can't make 3-d array.") ; return(NULL); } /* Allocating memeory for scanptr */ for (i = 0; i < row1; i++) { /* allocate memory for scanline */ dataptr[i] = Allocate_Array(row2,column); /*Initialize the Data Buffer */ if (!dataptr[i]) { printf(" Error : can't make row %d in [%d x %d x %d] matrix.\n", i,row1,row2, column); exit(1); } } return dataptr; } void Free_Array(void **dataptr,int row) { int i; for(i=0;i