00001 /* 00002 ** Copyright (C) 2005 by Kevin L. Mitchell <klmitch@mit.edu> 00003 ** 00004 ** This program is free software; you can redistribute it and/or modify 00005 ** it under the terms of the GNU General Public License as published by 00006 ** the Free Software Foundation; either version 2 of the License, or 00007 ** (at your option) any later version. 00008 ** 00009 ** This program is distributed in the hope that it will be useful, 00010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 ** GNU General Public License for more details. 00013 ** 00014 ** You should have received a copy of the GNU General Public License 00015 ** along with this program; if not, write to the Free Software 00016 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 ** 00018 ** @(#)$Id: event_attr_destroy.c,v 1.5 2005/06/04 17:57:03 klmitch Exp $ 00019 */ 00028 #include "event_int.h" 00029 00030 #include <stdlib.h> 00031 00032 RCSTAG("@(#)$Id: event_attr_destroy.c,v 1.5 2005/06/04 17:57:03 klmitch Exp $"); 00033 00034 ev_err_t 00035 event_attr_destroy(ev_attr_t *attr) 00036 { 00037 ev_varlist_t *vl_tmp, *vl_next; 00038 ev_overvars_t *ov_tmp, *ov_next; 00039 00040 ev_init(); /* initialize the library */ 00041 00042 if (!ea_verify(attr)) /* must be a valid attr */ 00043 ev_return(EINVAL); 00044 00045 /* Release all application-registered variables */ 00046 for (vl_tmp = ea_varlist(attr); vl_tmp; vl_tmp = vl_next) { 00047 vl_next = vl_tmp->vl_next; /* what comes next? */ 00048 00049 free(vl_tmp); /* release the memory */ 00050 } 00051 00052 /* Release all application-overridden variables */ 00053 for (ov_tmp = ea_ovars(attr); ov_tmp; ov_tmp = ov_next) { 00054 ov_next = ov_tmp->ov_next; /* what comes next? */ 00055 00056 free(ov_tmp); /* release the memory */ 00057 } 00058 00059 free(*attr); /* release the memory... */ 00060 00061 *attr = 0; /* and zero the caller's pointer */ 00062 00063 ev_return(0); /* all done! */ 00064 }