Example #1
0
void nlDeleteContext(NLContext context_in) {
	__NLContext* context = (__NLContext*)(context_in);
	if(__nlCurrentContext == context) {
		__nlCurrentContext = NULL;
	}
	if(context->alloc_M) {
		__nlSparseMatrixDestroy(&context->M);
	}
	if(context->alloc_af) {
		__nlRowColumnDestroy(&context->af);
	}
	if(context->alloc_al) {
		__nlRowColumnDestroy(&context->al);
	}
	if(context->alloc_variable) {
		__NL_DELETE_ARRAY(context->variable);
	}
	if(context->alloc_x) {
		__NL_DELETE_ARRAY(context->x);
	}
	if(context->alloc_b) {
		__NL_DELETE_ARRAY(context->b);
	}
	if (context->slu.alloc_slu) {
		__nlFree_SUPERLU(context);
	}

#ifdef NL_PARANOID
	__NL_CLEAR(__NLContext, context);
#endif
	__NL_DELETE(context);
}
Example #2
0
void nlDeleteContext(NLContext context_in) {
	__NLContext* context = (__NLContext*)(context_in);
	int i;

	if(__nlCurrentContext == context) {
		__nlCurrentContext = NULL;
	}
	if(context->alloc_M) {
		__nlSparseMatrixDestroy(&context->M);
	}
	if(context->alloc_MtM) {
		__nlSparseMatrixDestroy(&context->MtM);
	}
	if(context->alloc_variable) {
		for(i=0; i<context->nb_variables; i++) {
			if(context->variable[i].a) {
				__nlRowColumnDestroy(context->variable[i].a);
				__NL_DELETE(context->variable[i].a);
			}
		}

		__NL_DELETE_ARRAY(context->variable);
	}
	if(context->alloc_b) {
		__NL_DELETE_ARRAY(context->b);
	}
	if(context->alloc_Mtb) {
		__NL_DELETE_ARRAY(context->Mtb);
	}
	if(context->alloc_x) {
		__NL_DELETE_ARRAY(context->x);
	}
	if (context->slu.alloc_slu) {
		__nlFree_SUPERLU(context);
	}

#ifdef NL_PARANOID
	__NL_CLEAR(__NLContext, context);
#endif
	__NL_DELETE(context);
}