comparison src/http/modules/ngx_http_geoip_module.c @ 4649:95d93f7e6fa2

geoip: got rid of ugly casts when calling ngx_free(). This is done by removing the "const" qualifier from the common return type of handler functions returning either "const char *" or "char *".
author Ruslan Ermilov <ru@nginx.com>
date Tue, 29 May 2012 09:19:51 +0000
parents 70296867c740
children f57154322e0e
comparison
equal deleted inserted replaced
4648:70296867c740 4649:95d93f7e6fa2
26 ngx_str_t *name; 26 ngx_str_t *name;
27 uintptr_t data; 27 uintptr_t data;
28 } ngx_http_geoip_var_t; 28 } ngx_http_geoip_var_t;
29 29
30 30
31 typedef const char *(*ngx_http_geoip_variable_handler_pt)(GeoIP *, u_long addr); 31 typedef char *(*ngx_http_geoip_variable_handler_pt)(GeoIP *, u_long addr);
32 32
33 static u_long ngx_http_geoip_addr(ngx_http_request_t *r, 33 static u_long ngx_http_geoip_addr(ngx_http_request_t *r,
34 ngx_http_geoip_conf_t *gcf); 34 ngx_http_geoip_conf_t *gcf);
35 static ngx_int_t ngx_http_geoip_country_variable(ngx_http_request_t *r, 35 static ngx_int_t ngx_http_geoip_country_variable(ngx_http_request_t *r,
36 ngx_http_variable_value_t *v, uintptr_t data); 36 ngx_http_variable_value_t *v, uintptr_t data);
290 { 290 {
291 ngx_http_geoip_variable_handler_pt handler = 291 ngx_http_geoip_variable_handler_pt handler =
292 (ngx_http_geoip_variable_handler_pt) data; 292 (ngx_http_geoip_variable_handler_pt) data;
293 293
294 size_t len; 294 size_t len;
295 const char *val; 295 char *val;
296 ngx_http_geoip_conf_t *gcf; 296 ngx_http_geoip_conf_t *gcf;
297 297
298 gcf = ngx_http_get_module_main_conf(r, ngx_http_geoip_module); 298 gcf = ngx_http_get_module_main_conf(r, ngx_http_geoip_module);
299 299
300 if (gcf->org == NULL) { 300 if (gcf->org == NULL) {
308 } 308 }
309 309
310 len = ngx_strlen(val); 310 len = ngx_strlen(val);
311 v->data = ngx_pnalloc(r->pool, len); 311 v->data = ngx_pnalloc(r->pool, len);
312 if (v->data == NULL) { 312 if (v->data == NULL) {
313 ngx_free((void *) val); 313 ngx_free(val);
314 return NGX_ERROR; 314 return NGX_ERROR;
315 } 315 }
316 316
317 ngx_memcpy(v->data, val, len); 317 ngx_memcpy(v->data, val, len);
318 318
319 v->len = len; 319 v->len = len;
320 v->valid = 1; 320 v->valid = 1;
321 v->no_cacheable = 0; 321 v->no_cacheable = 0;
322 v->not_found = 0; 322 v->not_found = 0;
323 323
324 ngx_free((void *) val); 324 ngx_free(val);
325 325
326 return NGX_OK; 326 return NGX_OK;
327 327
328 not_found: 328 not_found:
329 329