Commit 3d0a8cf6 authored by Stefan Fritsch's avatar Stefan Fritsch
Browse files

Replace some "apr_p[c]alloc / memcpy" constructions into a single apr_pmemdup()s

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
parent 789ddeaf
Loading
Loading
Loading
Loading
+2 −4
Changes for modules/filters/mod_sed.c: 2 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -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) {
+1 −2
Changes for modules/generators/mod_cgid.c: 1 added line, 2 removed lines.
Original line number Diff line number Diff line
@@ -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));
+2 −2
Changes for modules/proxy/proxy_util.c: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -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) {