parser/hf.c
2bb60634
 /* 
  * $Id$ 
  */
 
 #include "hf.h"
 #include "parse_via.h"
 #include "parse_to.h"
 #include "parse_cseq.h"
 #include "../dprint.h"
 #include "../mem/mem.h"
 #include "parse_def.h"
8dd85148
 #include "digest/digest.h" /* free_credentials */
2bb60634
 
 
 /* 
  * Frees a hdr_field structure,
  * WARNING: it frees only parsed (and not name.s, body.s)
  */
 void clean_hdr_field(struct hdr_field* hf)
 {
 	if (hf->parsed){
 		switch(hf->type){
 		case HDR_VIA:
 			free_via_list(hf->parsed);
 			break;
 
 		case HDR_TO:
 			free_to(hf->parsed);
 			break;
 
 		case HDR_CSEQ:
 			free_cseq(hf->parsed);
 			break;
 
8dd85148
                 case HDR_AUTHORIZATION:
 		case HDR_PROXYAUTH:
7a212740
 			free_credentials((auth_body_t**)(&(hf->parsed)));
8dd85148
 			break;
 
31a22fdd
 		case HDR_FROM:
 			free_to(hf->parsed);
 			break;
 
2bb60634
 		default:
 			LOG(L_CRIT, "BUG: clean_hdr_field: unknown header type %d\n",
 			    hf->type);
 			break;
 		}
 	}
 }
 
 
 /* 
  * Frees a hdr_field list,
  * WARNING: frees only ->parsed and ->next*/
 void free_hdr_field_lst(struct hdr_field* hf)
 {
 	struct hdr_field* foo;
 	
 	while(hf) {
 		foo=hf;
 		hf=hf->next;
 		clean_hdr_field(foo);
 		pkg_free(foo);
 	}
 }