Bug 52648 - Code clean up (remove useless memory allocation)
Summary: Code clean up (remove useless memory allocation)
Status: RESOLVED FIXED
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: All (show other bugs)
Version: 2.5-HEAD
Hardware: PC Windows 2000
: P2 minor (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords: PatchAvailable
Depends on:
Blocks:
 
Reported: 2012-02-13 09:22 UTC by Christophe JAILLET
Modified: 2012-07-23 15:36 UTC (History)
0 users



Attachments
Proposed patch (2.86 KB, patch)
2012-02-13 09:22 UTC, Christophe JAILLET
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Christophe JAILLET 2012-02-13 09:22:33 UTC
Created attachment 28310 [details]
Proposed patch

Hi,

looking at the code, I have found 7 places where the r->request field is set.

mod_isapi.c
mod_asis.c
mod_cgi.c
mod_cgid.c
http_request.c
mod_proxy_scgi.c
protocol.c

Most of the time it is set using :
   r->method = apr_pstrdup(r->pool, "GET");


However, 'mod_proxy_scgi.c', only does :
   r->method = "GET";

I think that this is enough and that there is no need to 'apr_pstrdup' the name of the method. The attached patch removes these, IMO, useless copies.

Should I be wrong and the copy useful, then I think that 'mod_proxy_scgi.c' should be fixed to work as the other modules.
Comment 1 Takashi Sato 2012-02-13 14:47:12 UTC
The type of r->method is const char *, so I think you are right.
Comment 2 William A. Rowe Jr. 2012-02-13 22:26:09 UTC
Fixes look right.  pstrdup would have been appropriate from one pool context to
another pool context, but code strings will be outliving all other allocations.
Comment 3 Stefan Fritsch 2012-07-15 21:20:11 UTC
r1361803, thanks
Comment 4 Joe Orton 2012-07-23 15:36:45 UTC
r1364681 for 2.4.x