Klaus Demo nginx / 8ab0867
allocate cf->conf_file and cf->conf_file->buffer on stack Igor Sysoev 13 years ago
1 changed file(s) with 18 addition(s) and 24 deletion(s). Raw diff Collapse all Expand all
9797 char *rv;
9898 ngx_fd_t fd;
9999 ngx_int_t rc;
100 ngx_buf_t *b;
101 ngx_conf_file_t *prev;
100 ngx_buf_t buf;
101 ngx_conf_file_t *prev, conf_file;
102102 enum {
103103 parse_file = 0,
104104 parse_block,
124124
125125 prev = cf->conf_file;
126126
127 cf->conf_file = ngx_palloc(cf->pool, sizeof(ngx_conf_file_t));
128 if (cf->conf_file == NULL) {
129 return NGX_CONF_ERROR;
130 }
127 cf->conf_file = &conf_file;
131128
132129 if (ngx_fd_info(fd, &cf->conf_file->file.info) == -1) {
133130 ngx_log_error(NGX_LOG_EMERG, cf->log, ngx_errno,
134131 ngx_fd_info_n " \"%s\" failed", filename->data);
135132 }
136133
137 b = ngx_calloc_buf(cf->pool);
138 if (b == NULL) {
139 return NGX_CONF_ERROR;
140 }
141
142 cf->conf_file->buffer = b;
143
144 b->start = ngx_alloc(NGX_CONF_BUFFER, cf->log);
145 if (b->start == NULL) {
146 return NGX_CONF_ERROR;
147 }
148
149 b->pos = b->start;
150 b->last = b->start;
151 b->end = b->last + NGX_CONF_BUFFER;
152 b->temporary = 1;
134 cf->conf_file->buffer = &buf;
135
136 buf.start = ngx_alloc(NGX_CONF_BUFFER, cf->log);
137 if (buf.start == NULL) {
138 goto failed;
139 }
140
141 buf.pos = buf.start;
142 buf.last = buf.start;
143 buf.end = buf.last + NGX_CONF_BUFFER;
144 buf.temporary = 1;
153145
154146 cf->conf_file->file.fd = fd;
155147 cf->conf_file->file.name.len = filename->len;
255247 done:
256248
257249 if (filename) {
258 ngx_free(cf->conf_file->buffer->start);
250 if (cf->conf_file->buffer->start) {
251 ngx_free(cf->conf_file->buffer->start);
252 }
259253
260254 if (ngx_close_file(fd) == NGX_FILE_ERROR) {
261255 ngx_log_error(NGX_LOG_ALERT, cf->log, ngx_errno,
833827 name->len = len + old.len;
834828 name->data = ngx_pnalloc(cycle->pool, name->len + 1);
835829 if (name->data == NULL) {
836 return NGX_ERROR;
830 return NGX_ERROR;
837831 }
838832
839833 p = ngx_cpymem(name->data, prefix, len);