GLYLIB  0.3.0b
deallocate_utility_structures.c
Go to the documentation of this file.
00001 #include "../inc/mylib.h"
00002 #include "../inc/gly_codeutils.h"
00003 #include "../inc/gly_fileutils.h"
00004 
00005 /* \file deallocate_amber_structures.c 
00006 \addtogroup MEMORY_MANAGEMENT
00007 \brief   Dealloction routines for structures relevant to AMBER.
00008 
00009 Begun on 20100304 by BLFoley 
00010 
00011 Notes regarding these functions:
00012 
00013 * If a structure does not contain any pointers, it can just be freed.
00014 * Structures that contain pointers must have a deallocation function.
00015 * Single-pointers to arrays of simple types (e.g. int) may be freed.
00016 * Single-pointers to arrays of structures might need individual deallocation.
00017 * Double-pointers
00018         * Be very careful before freeing double-pointed structures
00019         *       -- they might point somewhere you don't want freed
00020         * Freeing the top-level pointer should not interfere with data below 
00021 */ 
00022 /********** structures from gly_codeutils.h ****************/
00023 void deallocateLlcharset(llcharset *l){
00024  if(l[0].T != NULL && l[0].T != 0x0){free(l[0].T);}
00025  return ;
00026 } 
00027 /********** structures from gly_fileutils.h ****************/
00028 void deallocateGlyKeysvals(gly_keysvals *gk){
00029  int i;
00030  // free each
00031  if(gk[0].K != NULL && gk[0].K != 0x0){
00032         for(i=0;i<gk[0].n;i++){if(gk[0].K[i] != NULL && gk[0].K[i] != 0x0){free(gk[0].K[i]);}}
00033         free(gk[0].K);}
00034  if(gk[0].V != NULL && gk[0].V != 0x0){
00035         for(i=0;i<gk[0].n;i++){if(gk[0].V[i] != NULL && gk[0].V[i] != 0x0){free(gk[0].V[i]);}}
00036         free(gk[0].V);}
00037  return ;
00038 }
00039 void deallocateFileset(fileset *f){
00040  //set null
00041  f[0].F = 0x0;
00042  if(f[0].N != NULL && f[0].N != 0x0){free(f[0].N);}
00043  return ;
00044 }
00045 void deallocateFileslurp(fileslurp *f){
00046  int i;
00047  if(f[0].L != NULL && f[0].L != 0x0){
00048         for(i=0;i<f[0].n;i++){if(f[0].L[i] != NULL && f[0].L[i] != 0x0){free(f[0].L[i]);}}
00049         free(f[0].L);}
00050  return ;
00051 }
00052 
 All Classes Files Functions Variables Typedefs Defines