]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
* Allocate the dav_liveprop_elem structure only once in the lifetime of the
authorRuediger Pluem <rpluem@apache.org>
Tue, 18 Jan 2022 20:13:29 +0000 (20:13 +0000)
committerRuediger Pluem <rpluem@apache.org>
Tue, 18 Jan 2022 20:13:29 +0000 (20:13 +0000)
  resource->pool and reuse it to avoid unnecessary huge memory allocations
  during collection walks.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1897182 13f79535-47bb-0310-9956-ffa450edef68

modules/dav/main/props.c

index dc5e5b7472b45d518e4d7239a6722e2d33c8b572..e1b6815cc8e0209bd096ccfe00c3defca56ebe53 100644 (file)
@@ -805,9 +805,15 @@ DAV_DECLARE(dav_get_props_result) dav_get_props(dav_propdb *propdb,
     /* we lose both the document and the element when calling (insert_prop),
      * make these available in the pool.
      */
-    element = apr_pcalloc(propdb->resource->pool, sizeof(dav_liveprop_elem));
+    element = dav_get_liveprop_element(propdb->resource);
+    if (!element) {
+        element = apr_pcalloc(propdb->resource->pool, sizeof(dav_liveprop_elem));
+        apr_pool_userdata_setn(element, DAV_PROP_ELEMENT, NULL, propdb->resource->pool);
+    }
+    else {
+        memset(element, 0, sizeof(dav_liveprop_elem));
+    }
     element->doc = doc;
-    apr_pool_userdata_setn(element, DAV_PROP_ELEMENT, NULL, propdb->resource->pool);
 
     /* ### NOTE: we should pass in TWO buffers -- one for keys, one for
        the marks */