You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by br...@apache.org on 2002/09/06 14:28:25 UTC
cvs commit: httpd-2.0/modules/experimental mod_mem_cache.c
brianp 2002/09/06 05:28:25
Modified: modules/experimental mod_mem_cache.c
Log:
Optimize away some strlen and memset calls
Revision Changes Path
1.81 +10 -6 httpd-2.0/modules/experimental/mod_mem_cache.c
Index: mod_mem_cache.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/experimental/mod_mem_cache.c,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -r1.80 -r1.81
--- mod_mem_cache.c 19 Aug 2002 22:13:18 -0000 1.80
+++ mod_mem_cache.c 6 Sep 2002 12:28:25 -0000 1.81
@@ -436,6 +436,7 @@
cache_object_t *obj, *tmp_obj;
mem_cache_object_t *mobj;
cache_type_e type_e;
+ apr_size_t key_len;
if (!strcasecmp(type, "mem")) {
type_e = CACHE_TYPE_HEAP;
@@ -476,12 +477,13 @@
if (!obj) {
return DECLINED;
}
- obj->key = calloc(1, strlen(key) + 1);
+ key_len = strlen(key) + 1;
+ obj->key = malloc(key_len);
if (!obj->key) {
cleanup_cache_object(obj);
return DECLINED;
}
- strncpy(obj->key, key, strlen(key) + 1);
+ memcpy(obj->key, key, key_len);
obj->info.len = len;
@@ -867,18 +869,20 @@
obj->info.expire = info->expire;
}
if (info->content_type) {
- obj->info.content_type = (char*) calloc(1, strlen(info->content_type) + 1);
+ apr_size_t len = strlen(info->content_type) + 1;
+ obj->info.content_type = (char*) malloc(len);
if (!obj->info.content_type) {
return APR_ENOMEM;
}
- strcpy(obj->info.content_type, info->content_type);
+ memcpy(obj->info.content_type, info->content_type, len);
}
if ( info->filename) {
- obj->info.filename = (char*) calloc(1, strlen(info->filename) + 1);
+ apr_size_t len = strlen(info->filename) + 1;
+ obj->info.filename = (char*) malloc(len);
if (!obj->info.filename ) {
return APR_ENOMEM;
}
- strcpy(obj->info.filename, info->filename );
+ memcpy(obj->info.filename, info->filename, len);
}
return APR_SUCCESS;