From: Martin Chan Newsgroups: comp.os.msdos.djgpp Subject: Memory allocation Date: Mon, 07 Feb 2000 21:16:37 +0800 Organization: CUHK Lines: 34 Message-ID: <389EC5B4.AA3D2666@mailserv.cuhk.edu.hk> NNTP-Posting-Host: dialup3-181.csc.cuhk.edu.hk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: justice.csc.cuhk.edu.hk 949929175 13601 137.189.210.181 (7 Feb 2000 13:12:55 GMT) X-Complaints-To: abuse AT cuhk DOT edu DOT hk NNTP-Posting-Date: 7 Feb 2000 13:12:55 GMT X-Mailer: Mozilla 4.7 [en] (Win95; I) X-Accept-Language: en To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Hi. I define a structure as below: typedef struct { int col, row; double **array; } *Matrix; Matrix transposed_matrix ; int col, i, row; and then create a 2-D dynamic array as below: transposed_matrix->array=(double**)calloc(row, sizeof(double*); --(transposed_matrix->array); /*offset pointer*/ for(i=1; i<=col; i++) { transposed_matrix->array[i]=(double*)calloc(col, sizeof(double)); --(transposed_matrix->array[i]); /*offset pointer*/ } Then, when I try to free the dynamic array as below: for(i=1; i<=col; i++) free(transposed_matrix->array[i]+1) free(transposed_matrix->array+1); General Protection Exception error happens. I am puzzled. Thanks for any help.