From: Andreas Schlick Date: Thu, 17 Feb 2011 21:58:44 +0000 (+0100) Subject: opt: Add a function to free the internal memory. X-Git-Url: http://git.ozlabs.org/?p=ccan;a=commitdiff_plain;h=6a6f64f541e5d09162e0ba8814e04feb13ff5e8f;hp=641d492d77d4248d4dac1e38635498b4e438fa7b opt: Add a function to free the internal memory. --- diff --git a/ccan/opt/opt.c b/ccan/opt/opt.c index 8f677400..f05d125f 100644 --- a/ccan/opt/opt.c +++ b/ccan/opt/opt.c @@ -201,6 +201,12 @@ bool opt_parse(int *argc, char *argv[], void (*errlog)(const char *fmt, ...)) return (ret == 0); } +void opt_free_table(void) +{ + free(opt_table); + opt_table=0; +} + void opt_log_stderr(const char *fmt, ...) { va_list ap; diff --git a/ccan/opt/opt.h b/ccan/opt/opt.h index 0748fe6a..57577785 100644 --- a/ccan/opt/opt.h +++ b/ccan/opt/opt.h @@ -183,6 +183,14 @@ void opt_register_table(const struct opt_table *table, const char *desc); */ bool opt_parse(int *argc, char *argv[], void (*errlog)(const char *fmt, ...)); +/** + * opt_free_table - free the table. + * + * This frees the internal memory. Call this as the last + * opt function. + */ +void opt_free_table(void); + /** * opt_log_stderr - print message to stderr. * @fmt: printf-style format.