comparison src/http/modules/ngx_http_sub_filter_module.c @ 6464:088ef087a011

Sub filter: fixed allocation alignment.
author Roman Arutyunyan <arut@nginx.com>
date Mon, 28 Mar 2016 13:35:25 +0300
parents fbbb1c1ce1eb
children f01ab2dbcfdc
comparison
equal deleted inserted replaced
6463:5df5d7d771f6 6464:088ef087a011
227 227
228 if (j == 0) { 228 if (j == 0) {
229 return ngx_http_next_header_filter(r); 229 return ngx_http_next_header_filter(r);
230 } 230 }
231 231
232 ctx->matches = ngx_pnalloc(r->pool, sizeof(ngx_array_t)); 232 ctx->matches = ngx_palloc(r->pool, sizeof(ngx_array_t));
233 if (ctx->matches == NULL) { 233 if (ctx->matches == NULL) {
234 return NGX_ERROR; 234 return NGX_ERROR;
235 } 235 }
236 236
237 ctx->matches->elts = matches; 237 ctx->matches->elts = matches;
238 ctx->matches->nelts = j; 238 ctx->matches->nelts = j;
239 239
240 ctx->tables = ngx_pnalloc(r->pool, sizeof(ngx_http_sub_tables_t)); 240 ctx->tables = ngx_palloc(r->pool, sizeof(ngx_http_sub_tables_t));
241 if (ctx->tables == NULL) { 241 if (ctx->tables == NULL) {
242 return NGX_ERROR; 242 return NGX_ERROR;
243 } 243 }
244 244
245 ngx_http_sub_init_tables(ctx->tables, ctx->matches->elts, 245 ngx_http_sub_init_tables(ctx->tables, ctx->matches->elts,
857 857
858 if (conf->pairs && conf->dynamic == 0 && conf->tables == NULL) { 858 if (conf->pairs && conf->dynamic == 0 && conf->tables == NULL) {
859 pairs = conf->pairs->elts; 859 pairs = conf->pairs->elts;
860 n = conf->pairs->nelts; 860 n = conf->pairs->nelts;
861 861
862 matches = ngx_pnalloc(cf->pool, sizeof(ngx_http_sub_match_t) * n); 862 matches = ngx_palloc(cf->pool, sizeof(ngx_http_sub_match_t) * n);
863 if (matches == NULL) { 863 if (matches == NULL) {
864 return NGX_CONF_ERROR; 864 return NGX_CONF_ERROR;
865 } 865 }
866 866
867 for (i = 0; i < n; i++) { 867 for (i = 0; i < n; i++) {
868 matches[i].match = pairs[i].match.value; 868 matches[i].match = pairs[i].match.value;
869 matches[i].value = &pairs[i].value; 869 matches[i].value = &pairs[i].value;
870 } 870 }
871 871
872 conf->matches = ngx_pnalloc(cf->pool, sizeof(ngx_array_t)); 872 conf->matches = ngx_palloc(cf->pool, sizeof(ngx_array_t));
873 if (conf->matches == NULL) { 873 if (conf->matches == NULL) {
874 return NGX_CONF_ERROR; 874 return NGX_CONF_ERROR;
875 } 875 }
876 876
877 conf->matches->elts = matches; 877 conf->matches->elts = matches;