]> git.kaiwu.me - nginx.git/commitdiff
use pointer to an array instead of array for inclusive locations inside location
authorIgor Sysoev <igor@sysoev.ru>
Tue, 5 Jun 2007 11:42:59 +0000 (11:42 +0000)
committerIgor Sysoev <igor@sysoev.ru>
Tue, 5 Jun 2007 11:42:59 +0000 (11:42 +0000)
src/http/modules/ngx_http_rewrite_module.c
src/http/ngx_http.c
src/http/ngx_http_core_module.c
src/http/ngx_http_core_module.h

index a5b96f8fd66b20b6e1c54bcdabc34254c22f727f..41cfc2d977756bd1de4e9e3264cd5619296802e4 100644 (file)
@@ -567,15 +567,14 @@ ngx_http_rewrite_if(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
     clcf->name = pclcf->name;
     clcf->noname = 1;
 
-    if (pclcf->locations.elts == NULL) {
-        if (ngx_array_init(&pclcf->locations, cf->pool, 4, sizeof(void *))
-            == NGX_ERROR)
-        {
+    if (pclcf->locations == NULL) {
+        pclcf->locations = ngx_array_create(cf->pool, 2, sizeof(void *));
+        if (pclcf->locations == NULL) {
             return NGX_CONF_ERROR;
         }
     }
 
-    clcfp = ngx_array_push(&pclcf->locations);
+    clcfp = ngx_array_push(pclcf->locations);
     if (clcfp == NULL) {
         return NGX_CONF_ERROR;
     }
index 46e576a90c5998e4a9e701acdd1f2195d3416161..c6bc6c5811eee574dda69153e8b93cebc982ed57 100644 (file)
@@ -1015,7 +1015,11 @@ ngx_http_merge_locations(ngx_conf_t *cf, ngx_array_t *locations,
             return rv;
         }
 
-        rv = ngx_http_merge_locations(cf, &clcfp[i]->locations,
+        if (clcfp[i]->locations == NULL) {
+            continue;
+        }
+
+        rv = ngx_http_merge_locations(cf, clcfp[i]->locations,
                                       clcfp[i]->loc_conf, module, ctx_index);
         if (rv != NGX_CONF_OK) {
             return rv;
index f6e14af0f2ba9f685d369bbf2febd2ea5e9916dd..5234a621fe261829178aa34ecd36760d436a969e 100644 (file)
@@ -1008,8 +1008,8 @@ ngx_http_core_find_location(ngx_http_request_t *r,
     if (found) {
         clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
 
-        if (clcf->locations.nelts) {
-            rc = ngx_http_core_find_location(r, &clcf->locations,
+        if (clcf->locations) {
+            rc = ngx_http_core_find_location(r, clcf->locations,
                                              clcf->regex_start, len);
 
             if (rc != NGX_OK) {
@@ -1793,15 +1793,15 @@ ngx_http_core_location(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy)
             return NGX_CONF_ERROR;
         }
 
-        if (pclcf->locations.elts == NULL) {
-            if (ngx_array_init(&pclcf->locations, cf->pool, 4, sizeof(void *))
-                != NGX_OK)
-            {
+        if (pclcf->locations == NULL) {
+            pclcf->locations = ngx_array_create(cf->pool, 2, sizeof(void *));
+
+            if (pclcf->locations == NULL) {
                 return NGX_CONF_ERROR;
             }
         }
 
-        clcfp = ngx_array_push(&pclcf->locations);
+        clcfp = ngx_array_push(pclcf->locations);
         if (clcfp == NULL) {
             return NGX_CONF_ERROR;
         }
@@ -1821,13 +1821,17 @@ ngx_http_core_location(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy)
         return rv;
     }
 
-    ngx_sort(clcf->locations.elts, (size_t) clcf->locations.nelts,
+    if (clcf->locations == NULL) {
+        return rv;
+    }
+
+    ngx_sort(clcf->locations->elts, (size_t) clcf->locations->nelts,
              sizeof(ngx_http_core_loc_conf_t *), ngx_http_core_cmp_locations);
 
-    clcf->regex_start = clcf->locations.nelts;
-    clcfp = clcf->locations.elts;
+    clcf->regex_start = clcf->locations->nelts;
+    clcfp = clcf->locations->elts;
 
-    for (i = 0; i < clcf->locations.nelts; i++) {
+    for (i = 0; i < clcf->locations->nelts; i++) {
         if (clcfp[i]->regex) {
             clcf->regex_start = i;
             break;
@@ -2855,15 +2859,14 @@ ngx_http_core_limit_except(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
     lcf->name = clcf->name;
     lcf->noname = 1;
 
-    if (clcf->locations.elts == NULL) {
-        if (ngx_array_init(&clcf->locations, cf->pool, 4, sizeof(void *))
-            == NGX_ERROR)
-        {
+    if (clcf->locations == NULL) {
+        clcf->locations = ngx_array_create(cf->pool, 2, sizeof(void *));
+        if (clcf->locations == NULL) {
             return NGX_CONF_ERROR;
         }
     }
 
-    clcfp = ngx_array_push(&clcf->locations);
+    clcfp = ngx_array_push(clcf->locations);
     if (clcfp == NULL) {
         return NGX_CONF_ERROR;
     }
index 9a8d629384b8ee2ffb1a5b0514d4f7491361f870..db1e0439a565adecda8795330df05856924865fb 100644 (file)
@@ -222,7 +222,7 @@ struct ngx_http_core_loc_conf_s {
     unsigned      alias:1;
 
     /* array of inclusive ngx_http_core_loc_conf_t */
-    ngx_array_t   locations;
+    ngx_array_t  *locations;
 
     /* pointer to the modules' loc_conf */
     void        **loc_conf ;