You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by yl...@apache.org on 2014/07/16 16:32:06 UTC

svn commit: r1611023 - /apr/apr/trunk/tables/apr_skiplist.c

Author: ylavic
Date: Wed Jul 16 14:32:05 2014
New Revision: 1611023

URL: http://svn.apache.org/r1611023
Log:
Three fixes:
- double size increment in insert_compare(),
- multiple apr_skiplist_free() called on the same value in remove_compare(),
- return 0 instead of NULL for void*.

Modified:
    apr/apr/trunk/tables/apr_skiplist.c

Modified: apr/apr/trunk/tables/apr_skiplist.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/tables/apr_skiplist.c?rev=1611023&r1=1611022&r2=1611023&view=diff
==============================================================================
--- apr/apr/trunk/tables/apr_skiplist.c (original)
+++ apr/apr/trunk/tables/apr_skiplist.c Wed Jul 16 14:32:05 2014
@@ -261,7 +261,7 @@ APR_DECLARE(void *) apr_skiplist_find(ap
     void *ret;
     apr_skiplistnode *aiter;
     if (!sl->compare) {
-        return 0;
+        return NULL;
     }
     if (iter) {
         ret = apr_skiplist_find_compare(sl, data, iter, sl->compare);
@@ -398,7 +398,7 @@ static apr_skiplistnode *insert_compare(
         }
         if (compared == 0 && replace) {
             free(stack);    /* OK. was malloc'ed */
-            return 0;
+            return NULL;
         }
         if ( (compared < 0) || (replace && (m->next == NULL)) ) {
             if (ch <= nh) {
@@ -434,7 +434,6 @@ static apr_skiplistnode *insert_compare(
         /* This sets ret to the bottom-most node we are inserting */
         if (!p) {
             ret = tmp;
-            sl->size++; /* this seems to go here got each element to be counted */
         }
         p = tmp;
     }
@@ -453,9 +452,6 @@ static apr_skiplistnode *insert_compare(
             li = ni;
         }
     }
-    else {
-        /* sl->size++; */
-    }
     sl->size++;
     return ret;
 }
@@ -463,7 +459,7 @@ static apr_skiplistnode *insert_compare(
 APR_DECLARE(apr_skiplistnode *) apr_skiplist_insert(apr_skiplist *sl, void *data)
 {
     if (!sl->compare) {
-        return 0;
+        return NULL;
     }
     return insert_compare(sl, data, sl->compare, 1);
 }
@@ -477,7 +473,7 @@ APR_DECLARE(apr_skiplistnode *) apr_skip
 APR_DECLARE(apr_skiplistnode *) apr_skiplist_add(apr_skiplist *sl, void *data)
 {
     if (!sl->compare) {
-        return 0;
+        return NULL;
     }
     return insert_compare(sl, data, sl->compare, 0);
 }
@@ -595,12 +591,13 @@ APR_DECLARE(void) apr_skiplist_remove_al
             myfree(p->data);
         while (m) {
             u = m->up;
-            apr_skiplist_free(sl, p);
+            apr_skiplist_free(sl, m);
             m = u;
         }
         m = p;
     }
     sl->top = sl->bottom = NULL;
+    sl->topend = sl->bottomend = NULL;
     sl->height = 0;
     sl->size = 0;
 }