From: Ruediger Pluem Date: Tue, 18 Jan 2022 20:13:29 +0000 (+0000) Subject: * Allocate the dav_liveprop_elem structure only once in the lifetime of the X-Git-Tag: 2.5.0-alpha2-ci-test-only~582 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e530aaaf8c4801d06da1b655caa284adf6eda9e5;p=thirdparty%2Fapache%2Fhttpd.git * Allocate the dav_liveprop_elem structure only once in the lifetime of the 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 --- diff --git a/modules/dav/main/props.c b/modules/dav/main/props.c index dc5e5b7472b..e1b6815cc8e 100644 --- a/modules/dav/main/props.c +++ b/modules/dav/main/props.c @@ -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 */