write_unsigned16 (&p_pos, p_end, template->fields_length);
write_unsigned16 (&p_pos, p_end, templ->fields_length);
int ipfix_end_template_set(ipfix_exporter *exporter, uint16_t template_id ){	int found_index;	char *p_pos;	char *p_end;	found_index=ipfix_find_template(exporter, template_id, UNCLEAN);	// test for a valid slot:	if ( (found_index < 0 ) || ( found_index >= exporter->ipfix_lo_template_maxsize ) ) {		fprintf (stderr, "Template not found. \n");		return -1;	}	// reallocate the memory , i.e. free superfluous memory, as we allocated enough memory to hold	// all possible vendor specific IDs.	ipfix_lo_template *template=(&(*exporter).template_arr[found_index]);	template->template_fields=realloc(template->template_fields, template->fields_length);	/*	 write the real length field:	 set pointers:	 beginning of the buffer	 */	p_pos =  (*exporter).template_arr[found_index].template_fields;	// end of the buffer	p_end = p_pos +  (*exporter).template_arr[found_index].max_fields_length;	// add offset of 2 bytes to the buffer's beginning: this is, where we will write to.	p_pos += 2;	// write the lenght field	write_unsigned16 (&p_pos, p_end, template->fields_length);	// call the template valid	template->valid = COMMITED;	// commit the template buffer to the sendbuffer	ipfix_update_template_sendbuffer(exporter);	return 0;}