zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mic...@apache.org
Subject svn commit: r1353689 - in /zookeeper/branches/branch-3.3: CHANGES.txt src/c/src/zk_hashtable.c
Date Mon, 25 Jun 2012 18:07:57 GMT
Author: michim
Date: Mon Jun 25 18:07:56 2012
New Revision: 1353689

URL: http://svn.apache.org/viewvc?rev=1353689&view=rev
Log:
ZOOKEEPER-1163. Memory leak in zk_hashtable.c:do_insert_watcher_object() (Anupam Chanda via
michim)

Modified:
    zookeeper/branches/branch-3.3/CHANGES.txt
    zookeeper/branches/branch-3.3/src/c/src/zk_hashtable.c

Modified: zookeeper/branches/branch-3.3/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.3/CHANGES.txt?rev=1353689&r1=1353688&r2=1353689&view=diff
==============================================================================
--- zookeeper/branches/branch-3.3/CHANGES.txt (original)
+++ zookeeper/branches/branch-3.3/CHANGES.txt Mon Jun 25 18:07:56 2012
@@ -22,6 +22,9 @@ BUGFIXES:
 
   ZOOKEEPER-1431. zkpython async calls leak memory (Kapil Thangavelu and Andre Cruz via henryr)
 
+  ZOOKEEPER-1163. Memory leak in zk_hashtable.c:do_insert_watcher_object()
+  (Anupam Chanda via michim)
+
 Release 3.3.5 - 2012-03-18
 Backward compatible changes:
 

Modified: zookeeper/branches/branch-3.3/src/c/src/zk_hashtable.c
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.3/src/c/src/zk_hashtable.c?rev=1353689&r1=1353688&r2=1353689&view=diff
==============================================================================
--- zookeeper/branches/branch-3.3/src/c/src/zk_hashtable.c (original)
+++ zookeeper/branches/branch-3.3/src/c/src/zk_hashtable.c Mon Jun 25 18:07:56 2012
@@ -189,8 +189,12 @@ static int do_insert_watcher_object(zk_h
         res=hashtable_insert(ht->ht,strdup(path),create_watcher_object_list(wo));
         assert(res);
     }else{
-        /* path already exists; check if the watcher already exists */
-        res = add_to_list(&wl, wo, 1);
+        /*
+         * Path already exists; check if the watcher already exists.
+         * Don't clone the watcher since it's allocated on the heap --- avoids
+         * a memory leak and saves a clone operation (calloc + copy).
+         */
+        res = add_to_list(&wl, wo, 0);
     }
     return res;    
 }



Mime
View raw message