[nginx] Use ngx_calloc_buf() where appropriate.

Ruslan Ermilov ru at nginx.com
Wed Apr 12 19:21:57 UTC 2017


details:   http://hg.nginx.org/nginx/rev/99934aade555
branches:  
changeset: 6973:99934aade555
user:      Ruslan Ermilov <ru at nginx.com>
date:      Wed Apr 12 22:21:04 2017 +0300
description:
Use ngx_calloc_buf() where appropriate.

diffstat:

 src/http/modules/ngx_http_flv_module.c          |  4 ++--
 src/http/modules/ngx_http_gzip_filter_module.c  |  2 +-
 src/http/modules/ngx_http_gzip_static_module.c  |  2 +-
 src/http/modules/ngx_http_image_filter_module.c |  6 +++---
 src/http/modules/ngx_http_mp4_module.c          |  2 +-
 src/http/modules/ngx_http_static_module.c       |  2 +-
 src/http/modules/ngx_http_xslt_filter_module.c  |  2 +-
 src/http/ngx_http_core_module.c                 |  2 +-
 src/http/ngx_http_file_cache.c                  |  2 +-
 9 files changed, 12 insertions(+), 12 deletions(-)

diffs (135 lines):

diff -r 6e8c249b34ea -r 99934aade555 src/http/modules/ngx_http_flv_module.c
--- a/src/http/modules/ngx_http_flv_module.c	Wed Apr 12 22:14:24 2017 +0300
+++ b/src/http/modules/ngx_http_flv_module.c	Wed Apr 12 22:21:04 2017 +0300
@@ -203,7 +203,7 @@ ngx_http_flv_handler(ngx_http_request_t 
     }
 
     if (i == 0) {
-        b = ngx_pcalloc(r->pool, sizeof(ngx_buf_t));
+        b = ngx_calloc_buf(r->pool);
         if (b == NULL) {
             return NGX_HTTP_INTERNAL_SERVER_ERROR;
         }
@@ -217,7 +217,7 @@ ngx_http_flv_handler(ngx_http_request_t 
     }
 
 
-    b = ngx_pcalloc(r->pool, sizeof(ngx_buf_t));
+    b = ngx_calloc_buf(r->pool);
     if (b == NULL) {
         return NGX_HTTP_INTERNAL_SERVER_ERROR;
     }
diff -r 6e8c249b34ea -r 99934aade555 src/http/modules/ngx_http_gzip_filter_module.c
--- a/src/http/modules/ngx_http_gzip_filter_module.c	Wed Apr 12 22:14:24 2017 +0300
+++ b/src/http/modules/ngx_http_gzip_filter_module.c	Wed Apr 12 22:21:04 2017 +0300
@@ -644,7 +644,7 @@ ngx_http_gzip_filter_gzheader(ngx_http_r
     static u_char  gzheader[10] =
                                { 0x1f, 0x8b, Z_DEFLATED, 0, 0, 0, 0, 0, 0, 3 };
 
-    b = ngx_pcalloc(r->pool, sizeof(ngx_buf_t));
+    b = ngx_calloc_buf(r->pool);
     if (b == NULL) {
         return NGX_ERROR;
     }
diff -r 6e8c249b34ea -r 99934aade555 src/http/modules/ngx_http_gzip_static_module.c
--- a/src/http/modules/ngx_http_gzip_static_module.c	Wed Apr 12 22:14:24 2017 +0300
+++ b/src/http/modules/ngx_http_gzip_static_module.c	Wed Apr 12 22:21:04 2017 +0300
@@ -248,7 +248,7 @@ ngx_http_gzip_static_handler(ngx_http_re
 
     /* we need to allocate all before the header would be sent */
 
-    b = ngx_pcalloc(r->pool, sizeof(ngx_buf_t));
+    b = ngx_calloc_buf(r->pool);
     if (b == NULL) {
         return NGX_HTTP_INTERNAL_SERVER_ERROR;
     }
diff -r 6e8c249b34ea -r 99934aade555 src/http/modules/ngx_http_image_filter_module.c
--- a/src/http/modules/ngx_http_image_filter_module.c	Wed Apr 12 22:14:24 2017 +0300
+++ b/src/http/modules/ngx_http_image_filter_module.c	Wed Apr 12 22:21:04 2017 +0300
@@ -581,7 +581,7 @@ ngx_http_image_json(ngx_http_request_t *
     size_t      len;
     ngx_buf_t  *b;
 
-    b = ngx_pcalloc(r->pool, sizeof(ngx_buf_t));
+    b = ngx_calloc_buf(r->pool);
     if (b == NULL) {
         return NULL;
     }
@@ -633,7 +633,7 @@ ngx_http_image_asis(ngx_http_request_t *
 {
     ngx_buf_t  *b;
 
-    b = ngx_pcalloc(r->pool, sizeof(ngx_buf_t));
+    b = ngx_calloc_buf(r->pool);
     if (b == NULL) {
         return NULL;
     }
@@ -1067,7 +1067,7 @@ transparent:
         return NULL;
     }
 
-    b = ngx_pcalloc(r->pool, sizeof(ngx_buf_t));
+    b = ngx_calloc_buf(r->pool);
     if (b == NULL) {
         gdFree(out);
         return NULL;
diff -r 6e8c249b34ea -r 99934aade555 src/http/modules/ngx_http_mp4_module.c
--- a/src/http/modules/ngx_http_mp4_module.c	Wed Apr 12 22:14:24 2017 +0300
+++ b/src/http/modules/ngx_http_mp4_module.c	Wed Apr 12 22:21:04 2017 +0300
@@ -636,7 +636,7 @@ ngx_http_mp4_handler(ngx_http_request_t 
     }
 
     if (mp4 == NULL) {
-        b = ngx_pcalloc(r->pool, sizeof(ngx_buf_t));
+        b = ngx_calloc_buf(r->pool);
         if (b == NULL) {
             return NGX_HTTP_INTERNAL_SERVER_ERROR;
         }
diff -r 6e8c249b34ea -r 99934aade555 src/http/modules/ngx_http_static_module.c
--- a/src/http/modules/ngx_http_static_module.c	Wed Apr 12 22:14:24 2017 +0300
+++ b/src/http/modules/ngx_http_static_module.c	Wed Apr 12 22:21:04 2017 +0300
@@ -233,7 +233,7 @@ ngx_http_static_handler(ngx_http_request
 
     /* we need to allocate all before the header would be sent */
 
-    b = ngx_pcalloc(r->pool, sizeof(ngx_buf_t));
+    b = ngx_calloc_buf(r->pool);
     if (b == NULL) {
         return NGX_HTTP_INTERNAL_SERVER_ERROR;
     }
diff -r 6e8c249b34ea -r 99934aade555 src/http/modules/ngx_http_xslt_filter_module.c
--- a/src/http/modules/ngx_http_xslt_filter_module.c	Wed Apr 12 22:14:24 2017 +0300
+++ b/src/http/modules/ngx_http_xslt_filter_module.c	Wed Apr 12 22:21:04 2017 +0300
@@ -584,7 +584,7 @@ ngx_http_xslt_apply_stylesheet(ngx_http_
         return NULL;
     }
 
-    b = ngx_pcalloc(r->pool, sizeof(ngx_buf_t));
+    b = ngx_calloc_buf(r->pool);
     if (b == NULL) {
         ngx_free(buf);
         return NULL;
diff -r 6e8c249b34ea -r 99934aade555 src/http/ngx_http_core_module.c
--- a/src/http/ngx_http_core_module.c	Wed Apr 12 22:14:24 2017 +0300
+++ b/src/http/ngx_http_core_module.c	Wed Apr 12 22:21:04 2017 +0300
@@ -1926,7 +1926,7 @@ ngx_http_send_response(ngx_http_request_
         return ngx_http_send_header(r);
     }
 
-    b = ngx_pcalloc(r->pool, sizeof(ngx_buf_t));
+    b = ngx_calloc_buf(r->pool);
     if (b == NULL) {
         return NGX_HTTP_INTERNAL_SERVER_ERROR;
     }
diff -r 6e8c249b34ea -r 99934aade555 src/http/ngx_http_file_cache.c
--- a/src/http/ngx_http_file_cache.c	Wed Apr 12 22:14:24 2017 +0300
+++ b/src/http/ngx_http_file_cache.c	Wed Apr 12 22:21:04 2017 +0300
@@ -1577,7 +1577,7 @@ ngx_http_cache_send(ngx_http_request_t *
 
     /* we need to allocate all before the header would be sent */
 
-    b = ngx_pcalloc(r->pool, sizeof(ngx_buf_t));
+    b = ngx_calloc_buf(r->pool);
     if (b == NULL) {
         return NGX_HTTP_INTERNAL_SERVER_ERROR;
     }


More information about the nginx-devel mailing list