| 485 return NULL; |
485 return NULL; |
| 486 } |
486 } |
| 487 return array; |
487 return array; |
| 488 } |
488 } |
| 489 |
489 |
| 490 void header_array_add(HeaderArray *hd, cxmutstr name, cxmutstr value) { |
490 int header_array_add(HeaderArray *hd, cxmutstr name, cxmutstr value) { |
| 491 while(hd->len >= hd->alloc) { |
491 while(hd->len >= hd->alloc) { |
| 492 if(hd->next == NULL) { |
492 if(hd->next == NULL) { |
| 493 HeaderArray *block = header_array_create(); |
493 HeaderArray *block = header_array_create(); |
| |
494 if(!block) { |
| |
495 return 1; |
| |
496 } |
| 494 hd->next = block; |
497 hd->next = block; |
| 495 } |
498 } |
| 496 hd = hd->next; |
499 hd = hd->next; |
| 497 } |
500 } |
| 498 hd->headers[hd->len].name = name; |
501 hd->headers[hd->len].name = name; |
| 499 hd->headers[hd->len].value = value; |
502 hd->headers[hd->len].value = value; |
| 500 hd->len++; |
503 hd->len++; |
| |
504 return 0; |
| 501 } |
505 } |
| 502 |
506 |
| 503 void header_array_free(HeaderArray *hd) { |
507 void header_array_free(HeaderArray *hd) { |
| |
508 if(!hd) { |
| |
509 return; |
| |
510 } |
| 504 HeaderArray *next; |
511 HeaderArray *next; |
| 505 while(hd) { |
512 while(hd) { |
| 506 next = hd->next; |
513 next = hd->next; |
| 507 free(hd->headers); |
514 free(hd->headers); |
| 508 free(hd); |
515 free(hd); |