Mercurial > hg > nginx
comparison src/http/ngx_http_core_module.c @ 1236:5e4d3b5d7ad0
use pointer to an array instead of array for inclusive locations inside location
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 05 Jun 2007 11:42:59 +0000 |
parents | f8a40ccafb04 |
children | 7dda762dcc9a |
comparison
equal
deleted
inserted
replaced
1235:f8a40ccafb04 | 1236:5e4d3b5d7ad0 |
---|---|
1006 } | 1006 } |
1007 | 1007 |
1008 if (found) { | 1008 if (found) { |
1009 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); | 1009 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); |
1010 | 1010 |
1011 if (clcf->locations.nelts) { | 1011 if (clcf->locations) { |
1012 rc = ngx_http_core_find_location(r, &clcf->locations, | 1012 rc = ngx_http_core_find_location(r, clcf->locations, |
1013 clcf->regex_start, len); | 1013 clcf->regex_start, len); |
1014 | 1014 |
1015 if (rc != NGX_OK) { | 1015 if (rc != NGX_OK) { |
1016 return rc; | 1016 return rc; |
1017 } | 1017 } |
1791 "location \"%V\" is outside location \"%V\"", | 1791 "location \"%V\" is outside location \"%V\"", |
1792 &clcf->name, &pclcf->name); | 1792 &clcf->name, &pclcf->name); |
1793 return NGX_CONF_ERROR; | 1793 return NGX_CONF_ERROR; |
1794 } | 1794 } |
1795 | 1795 |
1796 if (pclcf->locations.elts == NULL) { | 1796 if (pclcf->locations == NULL) { |
1797 if (ngx_array_init(&pclcf->locations, cf->pool, 4, sizeof(void *)) | 1797 pclcf->locations = ngx_array_create(cf->pool, 2, sizeof(void *)); |
1798 != NGX_OK) | 1798 |
1799 { | 1799 if (pclcf->locations == NULL) { |
1800 return NGX_CONF_ERROR; | 1800 return NGX_CONF_ERROR; |
1801 } | 1801 } |
1802 } | 1802 } |
1803 | 1803 |
1804 clcfp = ngx_array_push(&pclcf->locations); | 1804 clcfp = ngx_array_push(pclcf->locations); |
1805 if (clcfp == NULL) { | 1805 if (clcfp == NULL) { |
1806 return NGX_CONF_ERROR; | 1806 return NGX_CONF_ERROR; |
1807 } | 1807 } |
1808 } | 1808 } |
1809 | 1809 |
1819 | 1819 |
1820 if (rv != NGX_CONF_OK) { | 1820 if (rv != NGX_CONF_OK) { |
1821 return rv; | 1821 return rv; |
1822 } | 1822 } |
1823 | 1823 |
1824 ngx_sort(clcf->locations.elts, (size_t) clcf->locations.nelts, | 1824 if (clcf->locations == NULL) { |
1825 return rv; | |
1826 } | |
1827 | |
1828 ngx_sort(clcf->locations->elts, (size_t) clcf->locations->nelts, | |
1825 sizeof(ngx_http_core_loc_conf_t *), ngx_http_core_cmp_locations); | 1829 sizeof(ngx_http_core_loc_conf_t *), ngx_http_core_cmp_locations); |
1826 | 1830 |
1827 clcf->regex_start = clcf->locations.nelts; | 1831 clcf->regex_start = clcf->locations->nelts; |
1828 clcfp = clcf->locations.elts; | 1832 clcfp = clcf->locations->elts; |
1829 | 1833 |
1830 for (i = 0; i < clcf->locations.nelts; i++) { | 1834 for (i = 0; i < clcf->locations->nelts; i++) { |
1831 if (clcfp[i]->regex) { | 1835 if (clcfp[i]->regex) { |
1832 clcf->regex_start = i; | 1836 clcf->regex_start = i; |
1833 break; | 1837 break; |
1834 } | 1838 } |
1835 } | 1839 } |
2853 clcf->limit_except_loc_conf = ctx->loc_conf; | 2857 clcf->limit_except_loc_conf = ctx->loc_conf; |
2854 lcf->loc_conf = ctx->loc_conf; | 2858 lcf->loc_conf = ctx->loc_conf; |
2855 lcf->name = clcf->name; | 2859 lcf->name = clcf->name; |
2856 lcf->noname = 1; | 2860 lcf->noname = 1; |
2857 | 2861 |
2858 if (clcf->locations.elts == NULL) { | 2862 if (clcf->locations == NULL) { |
2859 if (ngx_array_init(&clcf->locations, cf->pool, 4, sizeof(void *)) | 2863 clcf->locations = ngx_array_create(cf->pool, 2, sizeof(void *)); |
2860 == NGX_ERROR) | 2864 if (clcf->locations == NULL) { |
2861 { | |
2862 return NGX_CONF_ERROR; | 2865 return NGX_CONF_ERROR; |
2863 } | 2866 } |
2864 } | 2867 } |
2865 | 2868 |
2866 clcfp = ngx_array_push(&clcf->locations); | 2869 clcfp = ngx_array_push(clcf->locations); |
2867 if (clcfp == NULL) { | 2870 if (clcfp == NULL) { |
2868 return NGX_CONF_ERROR; | 2871 return NGX_CONF_ERROR; |
2869 } | 2872 } |
2870 | 2873 |
2871 *clcfp = lcf; | 2874 *clcfp = lcf; |