rem: for(kid=node->xmlChildrenNode,foo=0;kid;kid=kid->next,foo++);
add: for(kid=node->children,foo=0;kid;kid=kid->next) if (kid->type==XML_ELEMENT_NODE) foo++;
context: int encode_node( xmlNodePtr node, unsigned char *p, unsigned char *p_end){	xmlNodePtr kid;	unsigned short sub_tree_size;	int attr_size;	int kid_size;	int foo;	/* counting the kids */	for(kid=node->xmlChildrenNode,foo=0;kid;kid=kid->next,foo++);	check_overflow(p,GET_NODE_SIZE(foo),p_end,error);	NR_OF_KIDS(p) = foo;	/* size of the encoded attributes */	attr_size = 0;	/* init the number of attributes */	NR_OF_ATTR(p) = 0;	/* encode node name */	switch (node->name[0]) {		case 'a':case 'A':			switch (node->name[7]) {				case 0:					NODE_TYPE(p) = ADDRESS_NODE;					attr_size = encode_address_attr( node, p, p_end);					break;				case '-':					NODE_TYPE(p) = ADDRESS_SWITCH_NODE;					attr_size = encode_address_switch_attr( node, p, p_end);					break;				default:					NODE_TYPE(p) = ANCILLARY_NODE;					break;			}			break;		case 'B':case 'b':			NODE_TYPE(p) = BUSY_NODE;			break;		case 'c':case 'C':			NODE_TYPE(p) = CPL_NODE;			break;		case 'd':case 'D':			NODE_TYPE(p) = DEFAULT_NODE;			break;		case 'f':case 'F':			NODE_TYPE(p) = FAILURE_NODE;			break;		case 'i':case 'I':			NODE_TYPE(p) = INCOMING_NODE;			break;		case 'l':case 'L':			switch (node->name[2]) {				case 'g':case 'G':					NODE_TYPE(p) = LOG_NODE;					attr_size = encode_log_attr( node, p, p_end);					break;				case 'o':case 'O':					NODE_TYPE(p) = LOOKUP_NODE;					/* we do not encode lookup node because we decide that it's					 * to unsecure to run it */					break;				case 'c':case 'C':					NODE_TYPE(p) = LOCATION_NODE;					attr_size = encode_location_attr( node, p, p_end);					break;				default:					if (node->name[8]) {						NODE_TYPE(p) = LANGUAGE_SWITCH_NODE;					} else {						NODE_TYPE(p) = LANGUAGE_NODE;						attr_size = encode_lang_attr( node, p, p_end);					}					break;			}			break;		case 'm':case 'M':			NODE_TYPE(p) =  MAIL_NODE;			attr_size = encode_mail_attr( node, p, p_end);			break;		case 'n':case 'N':			switch (node->name[3]) {				case 'F':case 'f':					NODE_TYPE(p) = NOTFOUND_NODE;					break;				case 'N':case 'n':					NODE_TYPE(p) = NOANSWER_NODE;					break;				default:					NODE_TYPE(p) = NOT_PRESENT_NODE;					break;			}			break;		case 'o':case 'O':			if (node->name[1]=='t' || node->name[1]=='T') {				NODE_TYPE(p) = OTHERWISE_NODE;			} else {				NODE_TYPE(p) = OUTGOING_NODE;			}			break;		case 'p':case 'P':			if (node->name[2]=='o' || node->name[2]=='O') {				NODE_TYPE(p) = PROXY_NODE;				attr_size = encode_proxy_attr( node, p, p_end);			} else if (node->name[8]) {				NODE_TYPE(p) = PRIORITY_SWITCH_NODE;			} else {				NODE_TYPE(p) = PRIORITY_NODE;				attr_size = encode_priority_attr( node, p, p_end);			}			break;		case 'r':case 'R':			switch (node->name[2]) {				case 'j':case 'J':					NODE_TYPE(p) = REJECT_NODE;					attr_size = encode_reject_attr( node, p, p_end);					break;				case 'm':case 'M':					NODE_TYPE(p) = REMOVE_LOCATION_NODE;					attr_size = encode_rmvloc_attr( node, p, p_end);					break;				default:					if (node->name[8]) {						NODE_TYPE(p) = REDIRECTION_NODE;					} else {						NODE_TYPE(p) = REDIRECT_NODE;						attr_size = encode_redirect_attr( node, p, p_end);					}					break;			}			break;		case 's':case 'S':			switch (node->name[3]) {				case 0:					NODE_TYPE(p) = SUB_NODE;					attr_size = encode_sub_attr( node, p, p_end);					break;				case 'c':case 'C':					NODE_TYPE(p) = SUCCESS_NODE;					break;				case 'a':case 'A':					NODE_TYPE(p) = SUBACTION_NODE;					attr_size = encode_subaction_attr( node, p, p_end);					break;				default:					if (node->name[6]) {						NODE_TYPE(p) = STRING_SWITCH_NODE;						attr_size = encode_string_switch_attr( node, p, p_end);					} else {						NODE_TYPE(p) = STRING_NODE;						attr_size = encode_string_attr( node, p, p_end);					}					break;			}			break;		case 't':case 'T':			if (node->name[4]) {				NODE_TYPE(p) = TIME_SWITCH_NODE;				attr_size = encode_time_switch_attr( node, p, p_end);			} else {				NODE_TYPE(p) = TIME_NODE;				attr_size = encode_time_attr( node, p, p_end);			}			break;		default:			LOG(L_ERR,"ERROR:cpl-c:encode_node: unknown node <%s>\n",				node->name);			goto error;	}	/* compute the total length of the node (including attributes) */	if (attr_size<0)		goto error;	sub_tree_size =  SIMPLE_NODE_SIZE(p) + (unsigned short)attr_size;	/* encrypt all the kids */	for(kid = node->xmlChildrenNode,foo=0;kid;kid=kid->next,foo++) {		SET_KID_OFFSET( p, foo, sub_tree_size);		kid_size = encode_node( kid, p+sub_tree_size, p_end);		if (kid_size<=0)			goto error;		sub_tree_size += (unsigned short)kid_size;	}	return sub_tree_size;error:	return -1;}