Procházet zdrojové kódy

kcore: free SE parsed body through generic hdr free framework

- the parser for session-expires header uses now the generic header free
  framework
Daniel-Constantin Mierla před 14 roky
rodič
revize
1f09236355
2 změnil soubory, kde provedl 13 přidání a 1 odebrání
  1. 12 1
      lib/kcore/parse_sst.c
  2. 1 0
      lib/kcore/parse_sst.h

+ 12 - 1
lib/kcore/parse_sst.c

@@ -68,6 +68,16 @@ malloc_session_expires( void )
 	return se;
 }
 
+/**
+ * wrapper to free the content of parsed session-expires header
+ */
+void hf_free_session_expires(void *parsed)
+{
+	struct session_expires *se;
+	se = (struct session_expires*)parsed;
+	free_session_expires(se);
+}
+
 
 void
 free_session_expires( struct session_expires *se )
@@ -84,7 +94,7 @@ parse_session_expires_body( struct hdr_field *hf )
 	int pos = 0;
 	int len = hf->body.len;
 	char *q;
-	struct session_expires se = { 0, sst_refresher_unspecified };
+	struct session_expires se = { 0, 0, sst_refresher_unspecified };
 	unsigned tok;
 
 	if ( !p || len <= 0 ) {
@@ -165,6 +175,7 @@ parse_session_expires_body( struct hdr_field *hf )
 		LM_ERR(" out of pkg memory\n" );
 		return parse_sst_out_of_mem;
 	}
+	se.hfree = hf_free_session_expires;
 	*((struct session_expires *)hf->parsed) = se;
 
 	return parse_sst_success;

+ 1 - 0
lib/kcore/parse_sst.h

@@ -53,6 +53,7 @@ enum sst_refresher {
  * a pointer to a struct session_expires.
  */
 struct session_expires {
+	hf_parsed_free_f hfree;       /* function to free the content */
 	unsigned            interval; /* in seconds */
 	enum sst_refresher  refresher;
 };