Browse code

In case the AVP is a regexp, an allocation is required to build an AVP "ident". The patch adds the functionality to free it.

Closes #SER-344.

Bogdan Pintea authored on 04/01/2009 15:34:54
Showing 2 changed files
... ...
@@ -981,6 +981,20 @@ error:
981 981
 	return -1;
982 982
 }
983 983
 
984
+void free_avp_ident(avp_ident_t* attr)
985
+{
986
+	if (attr->flags & AVP_NAME_RE) {
987
+		if (! attr->name.re) {
988
+			BUG("attr ident @%p has the regexp flag set, but no regexp.\n",
989
+					attr);
990
+#ifdef EXTRA_DEBUG
991
+			abort();
992
+#endif
993
+		} else {
994
+			pkg_free(attr->name.re);
995
+		}
996
+	}
997
+}
984 998
 
985 999
 int parse_avp_spec( str *name, int *type, int_str *avp_name, int *index)
986 1000
 {
... ...
@@ -203,7 +203,10 @@ int add_avp_galias(str *alias, int type, int_str avp_name);
203 203
 int parse_avp_ident( str *name, avp_ident_t* attr);
204 204
 int parse_avp_name( str *name, int *type, int_str *avp_name, int *index);
205 205
 int parse_avp_spec( str *name, int *type, int_str *avp_name, int *index);
206
+/* TODO: is there any client for this function? */
206 207
 void free_avp_name( int *type, int_str *avp_name);
208
+/* Free an ident obtained with parse_avp_ident() */
209
+void free_avp_ident(avp_ident_t* attr);
207 210
 
208 211
 /* AVP flags functions */
209 212
 #define MAX_AVPFLAG  ((unsigned int)( sizeof(avp_flags_t) * CHAR_BIT - 1 - AVP_CUSTOM_FLAGS))