[2719] in BarnOwl Developers

home help back first fref pref prev next nref lref last post

[PATCH] When deleting a variable, clean-up strings

daemon@ATHENA.MIT.EDU (David Benjamin)
Sat Oct 23 14:54:33 2010

From: David Benjamin <davidben@MIT.EDU>
To: barnowl-dev@mit.edu
Date: Sat, 23 Oct 2010 14:54:18 -0400
In-Reply-To: <alpine.DEB.1.10.1010231447430.15631@dr-wily.mit.edu>

Variables allocated from perl strdup their strings. Make this consistent
and free them afterwards.
---
 variable.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/variable.c b/variable.c
index 5380e62..c1c219f 100644
--- a/variable.c
+++ b/variable.c
@@ -480,6 +480,10 @@ int owl_variable_dict_setup(owl_vardict *vd) {
   for (var = variables_to_init; var->name != NULL; var++) {
     cur = owl_malloc(sizeof(owl_variable));
     *cur = *var;
+    /* strdup all the strings so we can delete them consistently. */
+    cur->name = owl_strdup(var->name);
+    cur->summary = owl_strdup(var->summary);
+    cur->description = owl_strdup(var->description);
     switch (cur->type) {
     case OWL_VARIABLE_OTHER:
       cur->set_fn(cur, cur->pval_default);
@@ -641,6 +645,9 @@ void owl_variable_dict_namelist_cleanup(owl_list *l)
 void owl_variable_delete(owl_variable *v)
 {
   if (v->delete_fn) v->delete_fn(v);
+  owl_free(v->name);
+  owl_free(v->summary);
+  owl_free(v->description);
   owl_free(v);
 }
 
-- 
1.7.3.1.g716de


home help back first fref pref prev next nref lref last post