I am trying to figure out a way to efficiently free the memory after a gsl matrix is no longer being used. Of course, one could call gsl_matrix_free(). However in my case, the block pointer may or may not be allocated.
A code snippet follows: gsl_matrix *matQ_temp = gsl_matrix_alloc(1,1); gsl_block_free(matQ_temp->block); matQ_temp->blcok = 0; if (matQ_temp->block!=0){ std::cout<<"true"<<std::endl; gsl_matrix_free(matQ_temp); } else{ std::cout<<"false"<<std::endl; free(matQ_temp->data); } When running this I get the following o/p: false *** glibc detected *** double free or corruption (!prev): 0x081b39a8 *** Aborted I thought even after gsl_block_free has been called, the data pointer needs to be freed. If yes, then why am I getting this error? Or does gsl_block_free() automatically free the data pointer as well? Also, is there anything else I need to do to free the memory? Thanks, Adarsh _______________________________________________ Help-gsl mailing list Help-gsl@gnu.org http://lists.gnu.org/mailman/listinfo/help-gsl