The find_entry() function in apr_hash.c is responsible for over
half the apr_pcalloc() calls in the httpd.  The calloc call
is somewhat wasteful in this context; 4 of the 5 fields in the
allocated struct get overwritten immediately.  Thus the following
patch replaces the calloc with an alloc and sets the one necessary
field to NULL.

--Brian

Index: apr/tables/apr_hash.c
===================================================================
RCS file: /home/cvspublic/apr/tables/apr_hash.c,v
retrieving revision 1.24
diff -u -r1.24 apr_hash.c
--- apr/tables/apr_hash.c    2001/08/02 03:18:44    1.24
+++ apr/tables/apr_hash.c    2001/09/06 06:07:51
@@ -278,7 +278,8 @@
    if (he || !val)
    return hep;
    /* add a new entry for non-NULL values */
-    he = apr_pcalloc(ht->pool, sizeof(*he));
+    he = apr_palloc(ht->pool, sizeof(*he));
+    he->next = NULL;
    he->hash = hash;
    he->key  = key;
    he->klen = klen;




Reply via email to