]> granicus.if.org Git - apache/commitdiff
Clean up size_t abuse, part 2. ap_malloc/calloc/realloc are explicitly
authorWilliam A. Rowe Jr <wrowe@apache.org>
Fri, 6 Jan 2012 18:15:08 +0000 (18:15 +0000)
committerWilliam A. Rowe Jr <wrowe@apache.org>
Fri, 6 Jan 2012 18:15:08 +0000 (18:15 +0000)
excluded from this cleanup as they must be signature identical to the
clib functions, and although the definition of size_t has been flakey,
the definition of those functions appears to be generally clean since
ANSI C.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1228323 13f79535-47bb-0310-9956-ffa450edef68

include/http_config.h
include/http_core.h
include/http_protocol.h
include/httpd.h
include/util_varbuf.h
server/config.c
server/core.c
server/protocol.c
server/request.c
server/util.c
server/util_cookies.c

index 40f0721443e1c99338180e5cfbb8c1639a4828ad..30ec368594b0b68fe40a48154f2723b93faed15a 100644 (file)
@@ -260,7 +260,7 @@ struct ap_configfile_t {
     /**< an apr_file_getc()-like function */
     apr_status_t (*getch) (char *ch, void *param);
     /**< an apr_file_gets()-like function */
-    apr_status_t (*getstr) (void *buf, size_t bufsiz, void *param);
+    apr_status_t (*getstr) (void *buf, apr_size_t bufsiz, void *param);
     /**< a close handler function */
     apr_status_t (*close) (void *param);
     /**< the argument passed to getch/getstr/close */
@@ -773,7 +773,7 @@ AP_DECLARE(ap_configfile_t *) ap_pcfg_open_custom(apr_pool_t *p,
     const char *descr,
     void *param,
     apr_status_t (*getc_func) (char *ch, void *param),
-    apr_status_t (*gets_func) (void *buf, size_t bufsiz, void *param),
+    apr_status_t (*gets_func) (void *buf, apr_size_t bufsiz, void *param),
     apr_status_t (*close_func) (void *param));
 
 /**
@@ -784,7 +784,7 @@ AP_DECLARE(ap_configfile_t *) ap_pcfg_open_custom(apr_pool_t *p,
  * @param cfp File to read from
  * @return error status, APR_ENOSPC if bufsize is too small for the line
  */
-AP_DECLARE(apr_status_t) ap_cfg_getline(char *buf, size_t bufsize, ap_configfile_t *cfp);
+AP_DECLARE(apr_status_t) ap_cfg_getline(char *buf, apr_size_t bufsize, ap_configfile_t *cfp);
 
 /**
  * Read one char from open configfile_t, increase line number upon LF
index 12a29e4279bb78c800b58cdfac65849fdd7a6419..81b36c75078b889df16296b526d99e1e26b0d784 100644 (file)
@@ -239,7 +239,7 @@ AP_DECLARE(apr_off_t) ap_get_limit_req_body(const request_rec *r);
  * @param r The current request
  * @return the maximum number of bytes in XML request msg body
  */
-AP_DECLARE(size_t) ap_get_limit_xml_body(const request_rec *r);
+AP_DECLARE(apr_size_t) ap_get_limit_xml_body(const request_rec *r);
 
 /**
  * Install a custom response handler for a given status
index 77493de586697633f9469b9fc376caa81b0a9c5b..377b8f1248c36bdc4fb5554aa81c56a8d95f7d81 100644 (file)
@@ -209,8 +209,10 @@ AP_DECLARE(apr_status_t) ap_send_fd(apr_file_t *fd, request_rec *r, apr_off_t of
  * @param length The amount of data to send
  * @return The number of bytes sent
  */
-AP_DECLARE(size_t) ap_send_mmap(apr_mmap_t *mm, request_rec *r, size_t offset,
-                             size_t length);
+AP_DECLARE(apr_size_t) ap_send_mmap(apr_mmap_t *mm,
+                                    request_rec *r,
+                                    apr_size_t offset,
+                                    apr_size_t length);
 #endif
 
 
index 19554b21080368fe29833f2d9ad54d9a6452b36f..2f41cc6bcc6f43a68de5163cd99df1d7e87bbb46 100644 (file)
@@ -1803,8 +1803,9 @@ AP_DECLARE(void) ap_pregfree(apr_pool_t *p, ap_regex_t *reg);
  * @param pmatch the pmatch array returned from ap_pregex
  * @return The substituted string, or NULL on error
  */
-AP_DECLARE(char *) ap_pregsub(apr_pool_t *p, const char *input, const char *source,
-                              size_t nmatch, ap_regmatch_t pmatch[]);
+AP_DECLARE(char *) ap_pregsub(apr_pool_t *p, const char *input,
+                              const char *source, apr_size_t nmatch,
+                              ap_regmatch_t pmatch[]);
 
 /**
  * After performing a successful regex match, you may use this function to
@@ -1822,7 +1823,8 @@ AP_DECLARE(char *) ap_pregsub(apr_pool_t *p, const char *input, const char *sour
  */
 AP_DECLARE(apr_status_t) ap_pregsub_ex(apr_pool_t *p, char **result,
                                        const char *input, const char *source,
-                                       size_t nmatch, ap_regmatch_t pmatch[],
+                                       apr_size_t nmatch,
+                                       ap_regmatch_t pmatch[],
                                        apr_size_t maxlen);
 
 /**
index cb5346f954efa25201fa4aabddb2191c224b4c17..1ae99f911e2b1fba440bb072b2930592249f4f58 100644 (file)
@@ -144,7 +144,8 @@ AP_DECLARE(char *) ap_varbuf_pdup(apr_pool_t *p, struct ap_varbuf *vb,
  */
 AP_DECLARE(apr_status_t) ap_varbuf_regsub(struct ap_varbuf *vb,
                                           const char *input,
-                                          const char *source, size_t nmatch,
+                                          const char *source,
+                                          apr_size_t nmatch,
                                           ap_regmatch_t pmatch[],
                                           apr_size_t maxlen);
 
index 8c56308b9ab43bce91c2e472f8d50a354af27aca..409ca0695ad13a7b86f9811e70fecaad71f3c2fc 100644 (file)
@@ -1648,7 +1648,7 @@ typedef struct {
 
 
 /* arr_elts_getstr() returns the next line from the string array. */
-static apr_status_t arr_elts_getstr(void *buf, size_t bufsiz, void *param)
+static apr_status_t arr_elts_getstr(void *buf, apr_size_t bufsiz, void *param)
 {
     arr_elts_param_t *arr_param = (arr_elts_param_t *)param;
     char *elt;
index 3caf9e7b952d6dd2c2fc19214613f37ae1ec19a0..b7d5ce31a66149fed6badc06cca793df84045c50 100644 (file)
@@ -64,7 +64,7 @@
 
 /* LimitXMLRequestBody handling */
 #define AP_LIMIT_UNSET                  ((long) -1)
-#define AP_DEFAULT_LIMIT_XML_BODY       ((size_t)1000000)
+#define AP_DEFAULT_LIMIT_XML_BODY       ((apr_size_t)1000000)
 
 #define AP_MIN_SENDFILE_BYTES           (256)
 
@@ -3347,7 +3347,7 @@ static const char *set_max_reversals(cmd_parms *cmd, void *conf_, const char *ar
     return NULL;
 }
 
-AP_DECLARE(size_t) ap_get_limit_xml_body(const request_rec *r)
+AP_DECLARE(apr_size_t) ap_get_limit_xml_body(const request_rec *r)
 {
     core_dir_config *conf;
 
@@ -3355,7 +3355,7 @@ AP_DECLARE(size_t) ap_get_limit_xml_body(const request_rec *r)
     if (conf->limit_xml_body == AP_LIMIT_UNSET)
         return AP_DEFAULT_LIMIT_XML_BODY;
 
-    return (size_t)conf->limit_xml_body;
+    return (apr_size_t)conf->limit_xml_body;
 }
 
 #if !defined (RLIMIT_CPU) || !(defined (RLIMIT_DATA) || defined (RLIMIT_VMEM) || defined(RLIMIT_AS)) || !defined (RLIMIT_NPROC)
index 8a6a4b3204467d3dca09661abcd10d1cd873d635..bdac160a1b26ce937eb11637bf6068fa42cddac2 100644 (file)
@@ -1462,8 +1462,10 @@ AP_DECLARE(apr_status_t) ap_send_fd(apr_file_t *fd, request_rec *r,
 
 #if APR_HAS_MMAP
 /* send data from an in-memory buffer */
-AP_DECLARE(size_t) ap_send_mmap(apr_mmap_t *mm, request_rec *r, size_t offset,
-                                size_t length)
+AP_DECLARE(apr_size_t) ap_send_mmap(apr_mmap_t *mm,
+                                    request_rec *r,
+                                    apr_size_t offset,
+                                    apr_size_t length)
 {
     conn_rec *c = r->connection;
     apr_bucket_brigade *bb = NULL;
index bb2a054de3b73c57ec730b5343326382c8c9fbd5..37cffdde04e5c2ff90c5ff09f6a1f3ab217f11af 100644 (file)
@@ -1033,7 +1033,7 @@ AP_DECLARE(int) ap_directory_walk(request_rec *r)
             seg_name = r->filename + filename_len;
             delim = strchr(r->path_info + (*r->path_info == '/' ? 1 : 0), '/');
             if (delim) {
-                size_t path_info_len = delim - r->path_info;
+                apr_size_t path_info_len = delim - r->path_info;
                 *delim = '\0';
                 memcpy(seg_name, r->path_info, path_info_len + 1);
                 filename_len += path_info_len;
@@ -1041,7 +1041,7 @@ AP_DECLARE(int) ap_directory_walk(request_rec *r)
                 *delim = '/';
             }
             else {
-                size_t path_info_len = strlen(r->path_info);
+                apr_size_t path_info_len = strlen(r->path_info);
                 memcpy(seg_name, r->path_info, path_info_len + 1);
                 filename_len += path_info_len;
                 r->path_info += path_info_len;
index 9ff8e394872a87e2b1d7983143afe23763f04662..3c38fa9008666250bfab46f78c359a53157df18e 100644 (file)
@@ -372,13 +372,13 @@ AP_DECLARE(const char *) ap_stripprefix(const char *bigstring,
 
 static apr_status_t regsub_core(apr_pool_t *p, char **result,
                                 struct ap_varbuf *vb, const char *input,
-                                const char *source, size_t nmatch,
+                                const char *source, apr_size_t nmatch,
                                 ap_regmatch_t pmatch[], apr_size_t maxlen)
 {
     const char *src = input;
     char *dst;
     char c;
-    size_t no;
+    apr_size_t no;
     apr_size_t len = 0;
 
     AP_DEBUG_ASSERT((result && p && !vb) || (vb && !p && !result));
@@ -465,7 +465,7 @@ static apr_status_t regsub_core(apr_pool_t *p, char **result,
 #define AP_PREGSUB_MAXLEN   (HUGE_STRING_LEN * 8)
 #endif
 AP_DECLARE(char *) ap_pregsub(apr_pool_t *p, const char *input,
-                              const char *source, size_t nmatch,
+                              const char *source, apr_size_t nmatch,
                               ap_regmatch_t pmatch[])
 {
     char *result;
@@ -478,7 +478,7 @@ AP_DECLARE(char *) ap_pregsub(apr_pool_t *p, const char *input,
 
 AP_DECLARE(apr_status_t) ap_pregsub_ex(apr_pool_t *p, char **result,
                                        const char *input, const char *source,
-                                       size_t nmatch, ap_regmatch_t pmatch[],
+                                       apr_size_t nmatch, ap_regmatch_t pmatch[],
                                        apr_size_t maxlen)
 {
     apr_status_t rc = regsub_core(p, result, NULL, input, source, nmatch,
@@ -725,7 +725,7 @@ AP_DECLARE(char *) ap_getword_nulls(apr_pool_t *atrans, const char **line,
     char *res;
 
     if (!pos) {
-        size_t len = strlen(*line);
+        apr_size_t len = strlen(*line);
         res = apr_pstrmemdup(atrans, *line, len);
         *line += len;
         return res;
@@ -836,7 +836,7 @@ static apr_status_t cfg_getch(char *ch, void *param)
     return apr_file_getc(ch, param);
 }
 
-static apr_status_t cfg_getstr(void *buf, size_t bufsiz, void *param)
+static apr_status_t cfg_getstr(void *buf, apr_size_t bufsiz, void *param)
 {
     return apr_file_gets(buf, bufsiz, param);
 }
@@ -926,7 +926,7 @@ AP_DECLARE(apr_status_t) ap_pcfg_openfile(ap_configfile_t **ret_cfg,
 AP_DECLARE(ap_configfile_t *) ap_pcfg_open_custom(
             apr_pool_t *p, const char *descr, void *param,
             apr_status_t (*getc_func) (char *ch, void *param),
-            apr_status_t (*gets_func) (void *buf, size_t bufsize, void *param),
+            apr_status_t (*gets_func) (void *buf, apr_size_t bufsize, void *param),
             apr_status_t (*close_func) (void *param))
 {
     ap_configfile_t *new_cfg = apr_palloc(p, sizeof(*new_cfg));
@@ -962,7 +962,7 @@ AP_DECLARE(const char *) ap_pcfg_strerror(apr_pool_t *p, ap_configfile_t *cfp,
 
 /* Read one line from open ap_configfile_t, strip LF, increase line number */
 /* If custom handler does not define a getstr() function, read char by char */
-static apr_status_t ap_cfg_getline_core(char *buf, size_t bufsize,
+static apr_status_t ap_cfg_getline_core(char *buf, apr_size_t bufsize,
                                         ap_configfile_t *cfp)
 {
     apr_status_t rc;
@@ -970,7 +970,7 @@ static apr_status_t ap_cfg_getline_core(char *buf, size_t bufsize,
     if (cfp->getstr != NULL) {
         char *cp;
         char *cbuf = buf;
-        size_t cbufsize = bufsize;
+        apr_size_t cbufsize = bufsize;
 
         while (1) {
             ++cfp->line_number;
@@ -1016,7 +1016,7 @@ static apr_status_t ap_cfg_getline_core(char *buf, size_t bufsize,
         }
     } else {
         /* No "get string" function defined; read character by character */
-        size_t i = 0;
+        apr_size_t i = 0;
 
         if (bufsize < 2) {
             /* too small, assume caller is crazy */
@@ -1081,7 +1081,8 @@ static int cfg_trim_line(char *buf)
 
 /* Read one line from open ap_configfile_t, strip LF, increase line number */
 /* If custom handler does not define a getstr() function, read char by char */
-AP_DECLARE(apr_status_t) ap_cfg_getline(char *buf, size_t bufsize, ap_configfile_t *cfp)
+AP_DECLARE(apr_status_t) ap_cfg_getline(char *buf, apr_size_t bufsize,
+                                        ap_configfile_t *cfp)
 {
     apr_status_t rc = ap_cfg_getline_core(buf, bufsize, cfp);
     if (rc == APR_SUCCESS)
@@ -2723,7 +2724,8 @@ AP_DECLARE(char *) ap_varbuf_pdup(apr_pool_t *p, struct ap_varbuf *buf,
 
 AP_DECLARE(apr_status_t) ap_varbuf_regsub(struct ap_varbuf *vb,
                                           const char *input,
-                                          const char *source, size_t nmatch,
+                                          const char *source,
+                                          apr_size_t nmatch,
                                           ap_regmatch_t pmatch[],
                                           apr_size_t maxlen)
 {
index dc8c457b778d9f3f32041a844e263e741b29c833..5139aecd4c48ec210025d8324647492fd78a80d0 100644 (file)
@@ -179,7 +179,7 @@ static int extract_cookie_line(ap_cookie_do * v, const char *key, const char *va
     char *last1, *last2;
     char *cookie = apr_pstrdup(v->r->pool, val);
     const char *name = apr_pstrcat(v->r->pool, v->name ? v->name : "", "=", NULL);
-    size_t len = strlen(name);
+    apr_size_t len = strlen(name);
     const char *new_cookie = "";
     const char *comma = ",";
     char *next1;