zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mic...@apache.org
Subject svn commit: r1547702 - in /zookeeper/trunk: CHANGES.txt src/c/src/cli.c src/c/src/zookeeper.c
Date Wed, 04 Dec 2013 04:14:53 GMT
Author: michim
Date: Wed Dec  4 04:14:52 2013
New Revision: 1547702

URL: http://svn.apache.org/r1547702
Log:
ZOOKEEPER-1632. fix memory leaks in cli_st (fpj via michim)

Modified:
    zookeeper/trunk/CHANGES.txt
    zookeeper/trunk/src/c/src/cli.c
    zookeeper/trunk/src/c/src/zookeeper.c

Modified: zookeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/trunk/CHANGES.txt?rev=1547702&r1=1547701&r2=1547702&view=diff
==============================================================================
--- zookeeper/trunk/CHANGES.txt (original)
+++ zookeeper/trunk/CHANGES.txt Wed Dec  4 04:14:52 2013
@@ -483,6 +483,8 @@ BUGFIXES:
   ZOOKEEPER-1821. very ugly warning when compiling load_gen.c
   (german blanco via fpj)
 
+  ZOOKEEPER-1632. fix memory leaks in cli_st (fpj via michim)
+
 IMPROVEMENTS:
 
   ZOOKEEPER-1170. Fix compiler (eclipse) warnings: unused imports,

Modified: zookeeper/trunk/src/c/src/cli.c
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/c/src/cli.c?rev=1547702&r1=1547701&r2=1547702&view=diff
==============================================================================
--- zookeeper/trunk/src/c/src/cli.c (original)
+++ zookeeper/trunk/src/c/src/cli.c Wed Dec  4 04:14:52 2013
@@ -182,12 +182,23 @@ void my_string_completion(int rc, const 
       shutdownThisThing=1;
 }
 
+void my_string_completion_free_data(int rc, const char *name, const void *data) {
+    my_string_completion(rc, name, data);
+    free((void*)data);
+}
+
 void my_string_stat_completion(int rc, const char *name, const struct Stat *stat,
         const void *data)  {
     my_string_completion(rc, name, data);
     dumpStat(stat);
 }
 
+void my_string_stat_completion_free_data(int rc, const char *name,
+        const struct Stat *stat, const void *data)  {
+    my_string_stat_completion(rc, name, stat, data);
+    free((void*)data);
+}
+
 void my_data_completion(int rc, const char *value, int value_len,
         const struct Stat *stat, const void *data) {
     struct timeval tv;
@@ -544,10 +555,10 @@ void processline(char *line) {
 //        }
         if (is_create2) {
           rc = zoo_acreate2(zh, line, "new", 3, &ZOO_OPEN_ACL_UNSAFE, flags,
-                my_string_stat_completion, strdup(line));
+                my_string_stat_completion_free_data, strdup(line));
         } else {
           rc = zoo_acreate(zh, line, "new", 3, &ZOO_OPEN_ACL_UNSAFE, flags,
-                  my_string_completion, strdup(line));
+                my_string_completion_free_data, strdup(line));
         }
         if (rc) {
             fprintf(stderr, "Error %d for %s\n", rc, line);
@@ -572,7 +583,7 @@ void processline(char *line) {
             fprintf(stderr, "Path must start with /, found: %s\n", line);
             return;
         }
-        rc = zoo_async(zh, line, my_string_completion, strdup(line));
+        rc = zoo_async(zh, line, my_string_completion_free_data, strdup(line));
         if (rc) {
             fprintf(stderr, "Error %d for %s\n", rc, line);
         }

Modified: zookeeper/trunk/src/c/src/zookeeper.c
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/c/src/zookeeper.c?rev=1547702&r1=1547701&r2=1547702&view=diff
==============================================================================
--- zookeeper/trunk/src/c/src/zookeeper.c (original)
+++ zookeeper/trunk/src/c/src/zookeeper.c Wed Dec  4 04:14:52 2013
@@ -417,6 +417,8 @@ static void destroy(zhandle_t *zh)
     destroy_zk_hashtable(zh->active_node_watchers);
     destroy_zk_hashtable(zh->active_exist_watchers);
     destroy_zk_hashtable(zh->active_child_watchers);
+    addrvec_free(&zh->addrs_old);
+    addrvec_free(&zh->addrs_new);
 }
 
 static void setup_random()



Mime
View raw message