search for: deferred_frees

Displaying 1 result from an estimated 1 matches for "deferred_frees".

Did you mean: deferred_free
2013 Jan 24
2
[PATCH 1/2] lib: Add CLEANUP_FREE macro which automatically calls 'free' when leaving scope.
...nup_free (void *ptr) +{ + free (* (void **) ptr); +} + +#ifndef HAVE_ATTRIBUTE_CLEANUP +void +guestfs___defer_free (guestfs_h *g, void (*freefn) (void *), void *data) +{ + struct deferred_free *p = safe_malloc (g, sizeof *p); + + p->freefn = freefn; + p->data = data; + p->next = g->deferred_frees; + g->deferred_frees = p; +} +#endif diff --git a/src/guestfs-internal.h b/src/guestfs-internal.h index 870207b..d27a3c2 100644 --- a/src/guestfs-internal.h +++ b/src/guestfs-internal.h @@ -72,6 +72,19 @@ #define TRACE4(name, arg1, arg2, arg3, arg4) #endif +#ifdef HAVE_ATTRIBUTE_CLEANUP +#d...