summaryrefslogtreecommitdiff
path: root/src/mod_webdav.c
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2022-12-10 15:15:33 -0500
committerGlenn Strauss <gstrauss@gluelogic.com>2022-12-10 15:15:33 -0500
commit5e14db43b7212b52f1cfcd2b0fce41df7fc419eb (patch)
tree1ae34085634983b89f972101f51785ce4d7ff30b /src/mod_webdav.c
parentabf470bebe446db762e01d04e894691390da7d45 (diff)
downloadlighttpd-git-5e14db43b7212b52f1cfcd2b0fce41df7fc419eb.tar.gz
[multiple] employ ck_calloc, ck_malloc shared code
employ ck_calloc(), ck_malloc() shared code to slightly reduce code size (centralize the ck_assert() to check that memory allocation succeeded)
Diffstat (limited to 'src/mod_webdav.c')
-rw-r--r--src/mod_webdav.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/mod_webdav.c b/src/mod_webdav.c
index 234da10d..ff5b0aa7 100644
--- a/src/mod_webdav.c
+++ b/src/mod_webdav.c
@@ -403,7 +403,7 @@ typedef struct {
INIT_FUNC(mod_webdav_init) {
- return calloc(1, sizeof(plugin_data));
+ return ck_calloc(1, sizeof(plugin_data));
}
@@ -1458,7 +1458,7 @@ SERVER_FUNC(mod_webdav_worker_init)
case 0: /* webdav.sqlite-db-name */
if (!buffer_is_blank(cpv->v.b)) {
const char * const dbname = cpv->v.b->ptr;
- cpv->v.v = calloc(1, sizeof(sql_config));
+ cpv->v.v = ck_calloc(1, sizeof(sql_config));
cpv->vtype = T_CONFIG_LOCAL;
if (!mod_webdav_sqlite3_prep(cpv->v.v, dbname, srv->errh))
return HANDLER_ERROR;
@@ -6076,13 +6076,9 @@ PHYSICALPATH_FUNC(mod_webdav_physical_handler)
mod_webdav_subrequest_handler(r, p_d); /*p->handle_subrequest()*/
if (rc == HANDLER_FINISHED || rc == HANDLER_ERROR)
r->plugin_ctx[((plugin_data *)p_d)->id] = NULL;
- else { /* e.g. HANDLER_WAIT_FOR_EVENT */
- plugin_config * const save_pconf =
- (plugin_config *)malloc(sizeof(pconf));
- force_assert(save_pconf);
- memcpy(save_pconf, &pconf, sizeof(pconf));
- r->plugin_ctx[((plugin_data *)p_d)->id] = save_pconf;
- }
+ else /* e.g. HANDLER_WAIT_FOR_EVENT */
+ r->plugin_ctx[((plugin_data *)p_d)->id] = /* save pconf */
+ memcpy(ck_malloc(sizeof(pconf)), &pconf, sizeof(pconf));
return rc;
}