Sfoglia il codice sorgente

core: pvapi: added pv_spec_free_contents()

Added pv_spec_free_contents() that behaves like pv_spec_free(),
but frees only the contents of the pv_spec and not the pv_spec
itself (good for cleaning up pv_specs that are part of other
structures).
Andrei Pelinescu-Onciul 15 anni fa
parent
commit
b4f455f834
2 ha cambiato i file con 14 aggiunte e 3 eliminazioni
  1. 13 3
      pvapi.c
  2. 1 0
      pvar.h

+ 13 - 3
pvapi.c

@@ -1075,15 +1075,25 @@ error:
 	return NULL;
 }
 
+
+
+/** frees only the contests of a pv_spec_t. */
+void pv_spec_free_contents(pv_spec_t *spec)
+{
+	/* TODO: free name if it is PV */
+	if(spec->trans)
+		tr_free((trans_t*)spec->trans);
+}
+
+
+
 /**
  *
  */
 void pv_spec_free(pv_spec_t *spec)
 {
 	if(spec==0) return;
-	/* TODO: free name if it is PV */
-	if(spec->trans)
-		tr_free((trans_t*)spec->trans);
+	pv_spec_free_contents(spec);
 	pkg_free(spec);
 }
 

+ 1 - 0
pvar.h

@@ -175,6 +175,7 @@ int pv_printf(struct sip_msg* msg, pv_elem_p list, char *buf, int *len);
 int pv_elem_free_all(pv_elem_p log);
 void pv_value_destroy(pv_value_t *val);
 void pv_spec_free(pv_spec_t *spec);
+void pv_spec_free_contents(pv_spec_t* spec);
 int pv_spec_dbg(pv_spec_p sp);
 int pv_get_spec_index(struct sip_msg* msg, pv_param_p ip, int *idx, int *flags);
 int pv_get_avp_name(struct sip_msg* msg, pv_param_p ip, int_str *avp_name,