From: Brian Pane Date: Fri, 6 Sep 2002 12:57:47 +0000 (+0000) Subject: More calloc->malloc optimizations X-Git-Tag: AGB_BEFORE_AAA_CHANGES~35 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=97bd3414164fb7f0d14c3162a022d38a6c967e0d;p=apache More calloc->malloc optimizations git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@96679 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/experimental/mod_mem_cache.c b/modules/experimental/mod_mem_cache.c index f7d7e44f76..bc65af1e78 100644 --- a/modules/experimental/mod_mem_cache.c +++ b/modules/experimental/mod_mem_cache.c @@ -660,7 +660,7 @@ static apr_status_t serialize_table(cache_header_tbl_t **obj, *obj=NULL; return APR_SUCCESS; } - *obj = calloc(1, sizeof(cache_header_tbl_t) * elts_arr->nelts); + *obj = malloc(sizeof(cache_header_tbl_t) * elts_arr->nelts); if (NULL == *obj) { return APR_ENOMEM; } @@ -671,7 +671,7 @@ static apr_status_t serialize_table(cache_header_tbl_t **obj, } /* Transfer the headers into a contiguous memory block */ - buf = calloc(1, len); + buf = malloc(len); if (!buf) { *obj = NULL; return APR_ENOMEM; @@ -680,12 +680,12 @@ static apr_status_t serialize_table(cache_header_tbl_t **obj, for (i = 0; i < *nelts; ++i) { (*obj)[i].hdr = &buf[idx]; len = strlen(elts[i].key) + 1; /* Include NULL terminator */ - strncpy(&buf[idx], elts[i].key, len); + memcpy(&buf[idx], elts[i].key, len); idx+=len; (*obj)[i].val = &buf[idx]; len = strlen(elts[i].val) + 1; - strncpy(&buf[idx], elts[i].val, len); + memcpy(&buf[idx], elts[i].val, len); idx+=len; } return APR_SUCCESS;