GF_Err gf_node_list_insert_child(GF_ChildNodeItem **list, GF_Node *n, u32 pos)
{
	GF_ChildNodeItem *child, *cur, *prev;
	u32 cur_pos = 0;

	assert(pos != (u32) -1);

	child = *list;

	cur = (GF_ChildNodeItem*) gf_malloc(sizeof(GF_ChildNodeItem));
	if (!cur) return GF_OUT_OF_MEM;
	cur->node = n;
	cur->next = NULL;
	prev = NULL;
	while (child) {
		if (pos==cur_pos) break;
		/*append*/
		if (!child->next) {
			child->next = cur;
			return GF_OK;
		}
		prev = child;
		child = child->next;
		cur_pos++;
	}
	cur->next = child;
	if (prev) prev->next = cur;
	else *list = cur;
	return GF_OK;
}
GF_Err gf_node_list_insert_child(GF_ChildNodeItem **list, GF_Node *n, u32 pos)
{
	GF_ChildNodeItem *child, *cur, *prev;
	u32 cur_pos = 0;

	assert(pos != (u32) -1);

	child = *list;

	cur = (GF_ChildNodeItem*) gf_malloc(sizeof(GF_ChildNodeItem));
	if (!cur) return GF_OUT_OF_MEM;
	cur->node = n;
	cur->next = NULL;
	prev = NULL;
	while (child) {
		if (pos==cur_pos) break;
		 
		if (!child->next) {
			child->next = cur;
			return GF_OK;
		}
		prev = child;
		child = child->next;
		cur_pos++;
	}
	cur->next = child;
	if (prev) prev->next = cur;
	else *list = cur;
	return GF_OK;
}