]> granicus.if.org Git - apache/commitdiff
Replace some "apr_p[c]alloc / memcpy" constructions into a single apr_pmemdup()s
authorStefan Fritsch <sf@apache.org>
Sat, 21 May 2011 21:06:15 +0000 (21:06 +0000)
committerStefan Fritsch <sf@apache.org>
Sat, 21 May 2011 21:06:15 +0000 (21:06 +0000)
PR: 51214
Submitted by: Christophe Jaillet <christophe jaillet wanadoo fr>

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

modules/filters/mod_sed.c
modules/generators/mod_cgid.c
modules/proxy/proxy_util.c

index 8c67706093c34e33c5da162216ea03a16e951cf3..64ff4bf80c3c851f9ab1249be7e336571b4afbc2 100644 (file)
@@ -138,8 +138,7 @@ static apr_status_t flush_output_buffer(sed_filter_ctxt *ctx)
     apr_status_t status = APR_SUCCESS;
     if ((ctx->outbuf == NULL) || (size <=0))
         return status;
-    out = apr_palloc(ctx->tpool, size);
-    memcpy(out, ctx->outbuf, size);
+    out = apr_pmemdup(ctx->tpool, ctx->outbuf, size);
     status = append_bucket(ctx, out, size);
     ctx->curoutbuf = ctx->outbuf;
     return status;
@@ -174,8 +173,7 @@ static apr_status_t sed_write_output(void *dummy, char *buf, int sz)
         /* if size is bigger than the allocated buffer directly add to output
          * brigade */
         if ((status == APR_SUCCESS) && (sz >= ctx->bufsize)) {
-            char* newbuf = apr_palloc(ctx->tpool, sz);
-            memcpy(newbuf, buf, sz);
+            char* newbuf = apr_pmemdup(ctx->tpool, buf, sz);
             status = append_bucket(ctx, newbuf, sz);
             /* pool might get clear after append_bucket */
             if (ctx->outbuf == NULL) {
index 5f3b2c4c88abc8323c9aa06b2eeb294d1d5e57cf..0df7f6d13d26dc0e500fc3bd8e39ba687583ce55 100644 (file)
@@ -847,8 +847,7 @@ static int cgid_server(void *data)
             key = &cgid_req.conn_id;
         }
         else {
-            key = apr_pcalloc(pcgi, sizeof(cgid_req.conn_id));
-            memcpy(key, &cgid_req.conn_id, sizeof(cgid_req.conn_id));
+            key = apr_pmemdup(pcgi, &cgid_req.conn_id, sizeof(cgid_req.conn_id));
         }
         apr_hash_set(script_hash, key, sizeof(cgid_req.conn_id),
                      (void *)((long)procnew->pid));
index 8339d40376a2599ebcc005984959d84002d49a77..e79d84bfdb6a6c33cd9ce9d1f0a1ea6eedd7b30d 100644 (file)
@@ -2618,8 +2618,8 @@ PROXY_DECLARE(int) ap_proxy_connect_backend(const char *proxy_function,
                      proxy_function, backend_addr->family, worker->s->hostname);
 
         if (conf->source_address_set) {
-            local_addr = apr_pcalloc(conn->pool, sizeof(apr_sockaddr_t));
-            memcpy(local_addr, conf->source_address, sizeof(apr_sockaddr_t));
+            local_addr = apr_pmemdup(conn->pool, conf->source_address,
+                                     sizeof(apr_sockaddr_t));
             local_addr->pool = conn->pool;
             rv = apr_socket_bind(newsock, local_addr);
             if (rv != APR_SUCCESS) {