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 19:38:04 UTC

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

Author: ylavic
Date: Wed Jul 16 17:38:03 2014
New Revision: 1611107

URL: http://svn.apache.org/r1611107
Log:
We do not garantee zero-ed memory for apr_skiplist_alloc(), neither in
the description, nor in the code for reused chunks.

So always allocate raw memory and don't rely on zero-ed one after internal
calls to apr_skiplist_alloc().

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=1611107&r1=1611106&r2=1611107&view=diff
==============================================================================
--- apr/apr/trunk/tables/apr_skiplist.c (original)
+++ apr/apr/trunk/tables/apr_skiplist.c Wed Jul 16 17:38:03 2014
@@ -52,10 +52,6 @@ struct apr_skiplistnode {
     apr_skiplist *sl;
 };
 
-#ifndef MIN
-#define MIN(a,b) ((a<b)?(a):(b))
-#endif
-
 static int get_b_rand(void)
 {
     static int ph = 32;         /* More bits than we will ever use */
@@ -103,7 +99,7 @@ APR_DECLARE(void *) apr_skiplist_alloc(a
             memlist++;
         }
         /* no free chunks */
-        ptr = apr_pcalloc(sl->pool, size);
+        ptr = apr_palloc(sl->pool, size);
         if (!ptr) {
             return ptr;
         }
@@ -122,7 +118,7 @@ APR_DECLARE(void *) apr_skiplist_alloc(a
         return ptr;
     }
     else {
-        return calloc(1, size);
+        return malloc(size);
     }
 }
 
@@ -348,15 +344,13 @@ static apr_skiplistnode *insert_compare(
         sl->height = 1;
         sl->topend = sl->bottomend = sl->top = sl->bottom =
             (apr_skiplistnode *)apr_skiplist_alloc(sl, sizeof(apr_skiplistnode));
-#if 0
-        sl->top->next = (apr_skiplistnode *)NULL;
-        sl->top->data = (apr_skiplistnode *)NULL;
-        sl->top->prev = (apr_skiplistnode *)NULL;
-        sl->top->up = (apr_skiplistnode *)NULL;
-        sl->top->down = (apr_skiplistnode *)NULL;
-        sl->top->nextindex = (apr_skiplistnode *)NULL;
-        sl->top->previndex = (apr_skiplistnode *)NULL;
-#endif
+        sl->top->next = NULL;
+        sl->top->data = NULL;
+        sl->top->prev = NULL;
+        sl->top->up = NULL;
+        sl->top->down = NULL;
+        sl->top->nextindex = NULL;
+        sl->top->previndex = NULL;
         sl->top->sl = sl;
     }
     if (sl->preheight) {