Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=fwsetup-ng.git;a=commitdiff;h=13c35069b9290c91b206d6aee5bfe16ddb061a81
commit 13c35069b9290c91b206d6aee5bfe16ddb061a81 Author: James Buren <[email protected]> Date: Tue Aug 14 15:09:56 2012 -0500 fully implement memory freeing functions for device/partition structs diff --git a/fwsetup.h b/fwsetup.h index af0220e..abeebae 100644 --- a/fwsetup.h +++ b/fwsetup.h @@ -123,6 +123,7 @@ extern void *list_find_start(void *list); extern void *list_find_end(void *list); extern void list_free(void *list,void (*cb) (void *)); extern void string_free(void *string); +extern void free_partition(void *p); extern struct device *read_device_data(const char *path); extern bool write_device_data(const struct device *device); extern void free_device(struct device *device); diff --git a/utility.c b/utility.c index 7ed0217..87f0464 100644 --- a/utility.c +++ b/utility.c @@ -245,8 +245,8 @@ extern void *list_find_end(void *list) extern void list_free(void *list,void (*cb) (void *)) { - assert(list != 0); - assert(cb != 0); + if(list == 0 || cb == 0) + return; struct list *a = list_find_start(list); struct list *b = 0; @@ -257,8 +257,6 @@ extern void list_free(void *list,void (*cb) (void *)) cb(a); - free(a); - a = b; } } @@ -272,6 +270,22 @@ extern void string_free(void *string) free(p->data); } +extern void free_partition(void *p) +{ + if(p == 0) + return; + + struct partition *partition = p; + + free(partition->type_s); + + free(partition->uuid); + + free(partition->name); + + free(partition); +} + extern struct device *read_device_data(const char *path) { assert(path != 0); @@ -540,6 +554,8 @@ extern void free_device(struct device *device) if(device == 0) return; + list_free(device->partitions,free_partition); + free(device->uuid); free(device->label); _______________________________________________ Frugalware-git mailing list [email protected] http://frugalware.org/mailman/listinfo/frugalware-git
