]> granicus.if.org Git - apache/commitdiff
Bypass a strdup and an 8KB local variable in the common case where
authorBrian Pane <brianp@apache.org>
Sun, 6 Jan 2002 08:01:34 +0000 (08:01 +0000)
committerBrian Pane <brianp@apache.org>
Sun, 6 Jan 2002 08:01:34 +0000 (08:01 +0000)
the logger is using the default time format

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

modules/loggers/mod_log_config.c

index ddcb8a7ee183a1d88ad499461f8203d4192094b2..b5b15a3718de44d52e4249ab46507295b891f63f 100644 (file)
@@ -450,7 +450,6 @@ static const char *log_request_time(request_rec *r, char *a)
 {
     apr_exploded_time_t xt;
     apr_size_t retcode;
-    char tstr[MAX_STRING_LEN];
 
     /*
        hi.  i think getting the time again at the end of the request
@@ -469,7 +468,9 @@ static const char *log_request_time(request_rec *r, char *a)
     ap_explode_recent_localtime(&xt, r->request_time);
 #endif
     if (a && *a) {              /* Custom format */
-        apr_strftime(tstr, &retcode, MAX_STRING_LEN, a, &xt);
+        char tstr[MAX_STRING_LEN];
+        apr_strftime(tstr, &retcode, sizeof(tstr), a, &xt);
+        return apr_pstrdup(r->pool, tstr);
     }
     else {                      /* CLF format */
        char sign;
@@ -484,13 +485,11 @@ static const char *log_request_time(request_rec *r, char *a)
            sign = '+';
        }
 
-        apr_snprintf(tstr, sizeof(tstr), "[%02d/%s/%d:%02d:%02d:%02d %c%.2d%.2d]",
+        return apr_psprintf(r->pool, "[%02d/%s/%d:%02d:%02d:%02d %c%.2d%.2d]",
                 xt.tm_mday, apr_month_snames[xt.tm_mon], xt.tm_year+1900,
                 xt.tm_hour, xt.tm_min, xt.tm_sec,
                 sign, timz / (60*60), timz % (60*60));
     }
-
-    return apr_pstrdup(r->pool, tstr);
 }
 
 static const char *log_request_duration(request_rec *r, char *a)