]> git.ozlabs.org Git - ccan/commitdiff
opt: Add a function to free the internal memory.
authorAndreas Schlick <ioerror@lavabit.com>
Thu, 17 Feb 2011 21:58:44 +0000 (22:58 +0100)
committerRusty Russell <rusty@rustcorp.com.au>
Tue, 22 Feb 2011 03:39:34 +0000 (14:09 +1030)
ccan/opt/opt.c
ccan/opt/opt.h

index 8f67740036e7e5c5ac53bb3c2abe8d5a9ccc7fce..f05d125fc828dda1e647a49788d5ccb1ac5b5d05 100644 (file)
@@ -201,6 +201,12 @@ bool opt_parse(int *argc, char *argv[], void (*errlog)(const char *fmt, ...))
        return (ret == 0);
 }
 
        return (ret == 0);
 }
 
+void opt_free_table(void)
+{
+       free(opt_table);
+       opt_table=0;
+}
+
 void opt_log_stderr(const char *fmt, ...)
 {
        va_list ap;
 void opt_log_stderr(const char *fmt, ...)
 {
        va_list ap;
index 0748fe6a7f0694f831ea94c85439d1a0ba65cc76..5757778577e2079b31641f176dd6976fe11c4d3d 100644 (file)
@@ -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, ...));
 
  */
 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.
 /**
  * opt_log_stderr - print message to stderr.
  * @fmt: printf-style format.