From: Paul Querna Date: Tue, 14 Jun 2005 00:16:48 +0000 (+0000) Subject: * cache/mod_disk_cache.c: Make most members of disk_cache_object into const char... X-Git-Tag: 2.1.5~16 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e54924f2acba362c15b1a58f9453768849f77c13;p=apache * cache/mod_disk_cache.c: Make most members of disk_cache_object into const char*. This removes the need to cast the const out in several places. * cache/mod_cache.h: Make cache_object.key a const. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@190535 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/cache/mod_cache.h b/modules/cache/mod_cache.h index 26675e7805..63416be36a 100644 --- a/modules/cache/mod_cache.h +++ b/modules/cache/mod_cache.h @@ -167,7 +167,7 @@ struct cache_info { */ typedef struct cache_object cache_object_t; struct cache_object { - char *key; + const char *key; cache_object_t *next; cache_info info; /* Opaque portion (specific to the implementation) of the cache object */ diff --git a/modules/cache/mod_disk_cache.c b/modules/cache/mod_disk_cache.c index 31d26e57be..887f187e3d 100644 --- a/modules/cache/mod_disk_cache.c +++ b/modules/cache/mod_disk_cache.c @@ -75,12 +75,12 @@ typedef struct { */ typedef struct disk_cache_object { const char *root; /* the location of the cache directory */ - char *tempfile; /* temp file tohold the content */ - char *datafile; /* name of file where the data will go */ - char *hdrsfile; /* name of file where the hdrs will go */ - char *hashfile; /* Computed hash key for this URI */ - char *name; /* Requested URI without vary bits - suitable for mortals. */ - char *key; /* On-disk prefix; URI with Vary bits (if present) */ + const char *tempfile; /* temp file tohold the content */ + const char *datafile; /* name of file where the data will go */ + const char *hdrsfile; /* name of file where the hdrs will go */ + const char *hashfile; /* Computed hash key for this URI */ + const char *name; /* Requested URI without vary bits - suitable for mortals. */ + const char *key; /* On-disk prefix; URI with Vary bits (if present) */ apr_file_t *fd; /* data file */ apr_file_t *hfd; /* headers file */ apr_file_t *tfd; /* temporary file for data */ @@ -146,12 +146,12 @@ static char *data_file(apr_pool_t *p, disk_cache_conf *conf, CACHE_DATA_SUFFIX, NULL); } -static void mkdir_structure(disk_cache_conf *conf, char *file, apr_pool_t *pool) +static void mkdir_structure(disk_cache_conf *conf, const char *file, apr_pool_t *pool) { apr_status_t rv; char *p; - for (p = file + conf->cache_root_len + 1;;) { + for (p = (char*)file + conf->cache_root_len + 1;;) { p = strchr(p, '/'); if (!p) break; @@ -255,8 +255,8 @@ static int file_cache_recall_mydata(apr_file_t *fd, cache_info *info, return APR_SUCCESS; } -static char* regen_key(apr_pool_t *p, apr_table_t *headers, - apr_array_header_t *varray, const char *oldkey) +static const char* regen_key(apr_pool_t *p, apr_table_t *headers, + apr_array_header_t *varray, const char *oldkey) { struct iovec *iov; int i, k; @@ -363,7 +363,7 @@ static int open_entity(cache_handle_t *h, request_rec *r, const char *key) { apr_uint32_t format; apr_size_t len; - char *nkey; + const char *nkey; apr_status_t rc; static int error_logged = 0; disk_cache_conf *conf = ap_get_module_config(r->server->module_config, @@ -448,12 +448,12 @@ static int open_entity(cache_handle_t *h, request_rec *r, const char *key) * start of the file again, so that later reads work. */ apr_file_seek(dobj->hfd, APR_SET, &offset); - nkey = (char*)key; + nkey = key; } obj->key = nkey; dobj->key = nkey; - dobj->name = (char*)key; + dobj->name = key; dobj->datafile = data_file(r->pool, conf, dobj, nkey); dobj->tempfile = apr_pstrcat(r->pool, conf->cache_root, AP_TEMPFILE, NULL); @@ -813,7 +813,7 @@ static apr_status_t store_headers(cache_handle_t *h, request_rec *r, cache_info iov[0].iov_base = (void*)&disk_info; iov[0].iov_len = sizeof(disk_cache_info_t); - iov[1].iov_base = dobj->name; + iov[1].iov_base = (void*)dobj->name; iov[1].iov_len = disk_info.name_len; rv = apr_file_writev(dobj->hfd, (const struct iovec *) &iov, 2, &amt);