[PATCH 2 of 4] Core: ngx_regex.c style cleanup

Maxim Dounin mdounin at mdounin.ru
Sun Dec 12 11:22:38 UTC 2021


# HG changeset patch
# User Maxim Dounin <mdounin at mdounin.ru>
# Date 1639235738 -10800
#      Sat Dec 11 18:15:38 2021 +0300
# Node ID c03ed58d70b6bd37acf289621d514a7497c8815e
# Parent  7b0522664bd790fda5d25df9087759953b30ac29
Core: ngx_regex.c style cleanup.

Notably, ngx_pcre_pool and ngx_pcre_studies are renamed to ngx_regex_pool
and ngx_regex_studies, respectively.

diff --git a/src/core/ngx_regex.c b/src/core/ngx_regex.c
--- a/src/core/ngx_regex.c
+++ b/src/core/ngx_regex.c
@@ -64,8 +64,8 @@ ngx_module_t  ngx_regex_module = {
 };
 
 
-static ngx_pool_t  *ngx_pcre_pool;
-static ngx_list_t  *ngx_pcre_studies;
+static ngx_pool_t  *ngx_regex_pool;
+static ngx_list_t  *ngx_regex_studies;
 
 
 void
@@ -79,14 +79,14 @@ ngx_regex_init(void)
 static ngx_inline void
 ngx_regex_malloc_init(ngx_pool_t *pool)
 {
-    ngx_pcre_pool = pool;
+    ngx_regex_pool = pool;
 }
 
 
 static ngx_inline void
 ngx_regex_malloc_done(void)
 {
-    ngx_pcre_pool = NULL;
+    ngx_regex_pool = NULL;
 }
 
 
@@ -112,13 +112,13 @@ ngx_regex_compile(ngx_regex_compile_t *r
            rc->err.len = ngx_snprintf(rc->err.data, rc->err.len,
                               "pcre_compile() failed: %s in \"%V\"",
                                errstr, &rc->pattern)
-                      - rc->err.data;
+                         - rc->err.data;
 
         } else {
            rc->err.len = ngx_snprintf(rc->err.data, rc->err.len,
                               "pcre_compile() failed: %s in \"%V\" at \"%s\"",
                                errstr, &rc->pattern, rc->pattern.data + erroff)
-                      - rc->err.data;
+                         - rc->err.data;
         }
 
         return NGX_ERROR;
@@ -133,8 +133,8 @@ ngx_regex_compile(ngx_regex_compile_t *r
 
     /* do not study at runtime */
 
-    if (ngx_pcre_studies != NULL) {
-        elt = ngx_list_push(ngx_pcre_studies);
+    if (ngx_regex_studies != NULL) {
+        elt = ngx_list_push(ngx_regex_studies);
         if (elt == NULL) {
             goto nomem;
         }
@@ -229,11 +229,8 @@ ngx_regex_exec_array(ngx_array_t *a, ngx
 static void * ngx_libc_cdecl
 ngx_regex_malloc(size_t size)
 {
-    ngx_pool_t      *pool;
-    pool = ngx_pcre_pool;
-
-    if (pool) {
-        return ngx_palloc(pool, size);
+    if (ngx_regex_pool) {
+        return ngx_palloc(ngx_regex_pool, size);
     }
 
     return NULL;
@@ -286,10 +283,10 @@ ngx_regex_cleanup(void *data)
 
     /*
      * On configuration parsing errors ngx_regex_module_init() will not
-     * be called.  Make sure ngx_pcre_studies is properly cleared anyway.
+     * be called.  Make sure ngx_regex_studies is properly cleared anyway.
      */
 
-    ngx_pcre_studies = NULL;
+    ngx_regex_studies = NULL;
 }
 
 
@@ -357,7 +354,7 @@ ngx_regex_module_init(ngx_cycle_t *cycle
 
     ngx_regex_malloc_done();
 
-    ngx_pcre_studies = NULL;
+    ngx_regex_studies = NULL;
 
     return NGX_OK;
 }
@@ -389,7 +386,7 @@ ngx_regex_create_conf(ngx_cycle_t *cycle
         return NULL;
     }
 
-    ngx_pcre_studies = rcf->studies;
+    ngx_regex_studies = rcf->studies;
 
     return rcf;
 }



More information about the nginx-devel mailing list