Browse Source

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 16 years ago
parent
commit
5137b02df4
2 changed files with 17 additions and 0 deletions
  1. 14 0
      usr_avp.c
  2. 3 0
      usr_avp.h

+ 14 - 0
usr_avp.c

@@ -981,6 +981,20 @@ error:
 	return -1;
 }
 
+void free_avp_ident(avp_ident_t* attr)
+{
+	if (attr->flags & AVP_NAME_RE) {
+		if (! attr->name.re) {
+			BUG("attr ident @%p has the regexp flag set, but no regexp.\n",
+					attr);
+#ifdef EXTRA_DEBUG
+			abort();
+#endif
+		} else {
+			pkg_free(attr->name.re);
+		}
+	}
+}
 
 int parse_avp_spec( str *name, int *type, int_str *avp_name, int *index)
 {

+ 3 - 0
usr_avp.h

@@ -203,7 +203,10 @@ int add_avp_galias(str *alias, int type, int_str avp_name);
 int parse_avp_ident( str *name, avp_ident_t* attr);
 int parse_avp_name( str *name, int *type, int_str *avp_name, int *index);
 int parse_avp_spec( str *name, int *type, int_str *avp_name, int *index);
+/* TODO: is there any client for this function? */
 void free_avp_name( int *type, int_str *avp_name);
+/* Free an ident obtained with parse_avp_ident() */
+void free_avp_ident(avp_ident_t* attr);
 
 /* AVP flags functions */
 #define MAX_AVPFLAG  ((unsigned int)( sizeof(avp_flags_t) * CHAR_BIT - 1 - AVP_CUSTOM_FLAGS))