Browse code

core: xavp - helper function to remove child value

Daniel-Constantin Mierla authored on 18/04/2019 07:37:36
Showing 2 changed files
... ...
@@ -447,6 +447,20 @@ int xavp_rm_by_index(str *name, int idx, sr_xavp_t **head)
447 447
 	return xavp_rm_internal(name, head, idx);
448 448
 }
449 449
 
450
+int xavp_rm_child_by_index(str *rname, str *cname, int idx)
451
+{
452
+	sr_xavp_t *avp=NULL;
453
+
454
+	if (idx<0) {
455
+		return 0;
456
+	}
457
+	avp = xavp_get(rname, NULL);
458
+
459
+	if(avp == NULL || avp->val.type!=SR_XTYPE_XAVP) {
460
+		return 0;
461
+	}
462
+	return xavp_rm_internal(cname, &avp->val.v.xavp, idx);
463
+}
450 464
 
451 465
 int xavp_count(str *name, sr_xavp_t **start)
452 466
 {
... ...
@@ -88,6 +88,7 @@ sr_xavp_t *xavp_get_last(str *xname, sr_xavp_t **list);
88 88
 int xavp_rm_by_name(str *name, int all, sr_xavp_t **head);
89 89
 int xavp_rm_by_index(str *name, int idx, sr_xavp_t **head);
90 90
 int xavp_rm(sr_xavp_t *xa, sr_xavp_t **head);
91
+int xavp_rm_child_by_index(str *rname, str *cname, int idx);
91 92
 int xavp_count(str *name, sr_xavp_t **start);
92 93
 void xavp_destroy_list_unsafe(sr_xavp_t **head);
93 94
 void xavp_destroy_list(sr_xavp_t **head);