src/server/daemon/httprequest.c

changeset 662
70fdf948b642
parent 660
f00d03835dd9
child 665
b8d5b797d090
equal deleted inserted replaced
661:a4e1ba59b733 662:70fdf948b642
469 469
470 return 0; 470 return 0;
471 } 471 }
472 472
473 473
474 474 HeaderArray* header_array_create(void) {
475 void header_add(HeaderArray *hd, cxmutstr name, cxmutstr value) { 475 HeaderArray *array = malloc(sizeof(HeaderArray));
476 if(!array) {
477 return NULL;
478 }
479 array->next = NULL;
480 array->len = 0;
481 array->alloc = 16;
482 array->headers = calloc(16, sizeof(Header));
483 if(array->headers) {
484 free(array);
485 return NULL;
486 }
487 return array;
488 }
489
490 void header_array_add(HeaderArray *hd, cxmutstr name, cxmutstr value) {
476 while(hd->len >= hd->alloc) { 491 while(hd->len >= hd->alloc) {
477 if(hd->next == NULL) { 492 if(hd->next == NULL) {
478 HeaderArray *block = malloc(sizeof(HeaderArray)); 493 HeaderArray *block = header_array_create();
479 block->next = NULL;
480 block->len = 0;
481 block->headers = calloc(16, sizeof(Header));
482 block->alloc = 16;
483 hd->next = block; 494 hd->next = block;
484 } 495 }
485 hd = hd->next; 496 hd = hd->next;
486 } 497 }
487 hd->headers[hd->len].name = name; 498 hd->headers[hd->len].name = name;

mercurial