/**************************************************************************\ * These two subroutines together delete the entire constraint structure. * * The second subroutine deletes just a single object completely, and * * the first subroutine simply links them together. * \**************************************************************************/ #include #include "nrutil.h" #include "structs.h" void del_constr_struct (struct cons *constr) { void del_one_cons (struct cons *constr); if (constr->next != NULL) { del_one_cons (constr->next); constr->next = NULL; }; del_one_cons (constr); } /**************************************\ * Delete a single object completely. * \**************************************/ void del_one_cons (struct cons *constr) { /*---------------------------------------------------------------------\ | Note that the truncation mirror parameters are merely pointers, so | | we don't need to free individual fpar->a, ia, outer, etc.. But, | | we do need to free the structure which holds those parameters. | | Also, we don't need to delete fpar->high->high parameters, because | | it is itself entirely a pointer back to fpar->trunc->high, i.e. | | high order terms for the truncation function. | \---------------------------------------------------------------------*/ if ( constr != NULL ) { if (constr->comp != NULL) free ((int *)constr->comp); if (constr->par != NULL) free ((int *)constr->par); if (constr->cval != NULL) free ((int *)constr->cval); } free ((struct cons *) constr); }