if (bt->setID == NetflowV9_SetId_Template) { free(bt->templateInfo->fieldInfo);   int n; for (n = 0; n < templateBuffer->ipfixParser->callbackCount; n++) { CallbackInfo* ci = &templateBuffer->ipfixParser->callbackInfo[n]; if (ci->templateDestructionCallbackFunction) ci->templateDestructionCallbackFunction(ci->handle, sourceId, bt->templateInfo);
if (bt->setID == NetflowV9_SetId_Template) { free(bt->templateInfo->fieldInfo);   int n; for (n = 0; n < templateBuffer->ipfixParser->callbackCount; n++) { CallbackInfo* ci = &templateBuffer->ipfixParser->callbackInfo[n]; if (ci->templateDestructionCallbackFunction) { ci->templateDestructionCallbackFunction(ci->handle, sourceId, bt->templateInfo); }
void destroyBufferedTemplate(TemplateBuffer* templateBuffer, SourceID sourceId, TemplateID templateId) {	BufferedTemplate* predecessor = 0;	BufferedTemplate* bt = templateBuffer->head;	while (bt != 0) {		if ((bt->sourceID == sourceId) && (bt->templateID == templateId)) break;		predecessor = bt;		bt = (BufferedTemplate*)bt->next;		}	if (bt == 0) return;	if (predecessor != 0) {		predecessor->next = bt->next;		} else {		templateBuffer->head = (BufferedTemplate*)bt->next;		}	if (bt->setID == IPFIX_SetId_Template) {		free(bt->templateInfo->fieldInfo);		/* Invoke all registered callback functions */		int n;				for (n = 0; n < templateBuffer->ipfixParser->callbackCount; n++) {			CallbackInfo* ci = &templateBuffer->ipfixParser->callbackInfo[n];			if (ci->templateDestructionCallbackFunction) ci->templateDestructionCallbackFunction(ci->handle, sourceId, bt->templateInfo);			}		free(bt->templateInfo);		} else#ifdef SUPPORT_NETFLOWV9	if (bt->setID == NetflowV9_SetId_Template) {		free(bt->templateInfo->fieldInfo);		/* Invoke all registered callback functions */		int n;				for (n = 0; n < templateBuffer->ipfixParser->callbackCount; n++) {			CallbackInfo* ci = &templateBuffer->ipfixParser->callbackInfo[n];			if (ci->templateDestructionCallbackFunction) ci->templateDestructionCallbackFunction(ci->handle, sourceId, bt->templateInfo);			}		free(bt->templateInfo);		} else#endif	if (bt->setID == IPFIX_SetId_OptionsTemplate) {		free(bt->optionsTemplateInfo->scopeInfo);		free(bt->optionsTemplateInfo->fieldInfo);		/* Invoke all registered callback functions */		int n;				for (n = 0; n < templateBuffer->ipfixParser->callbackCount; n++) {			CallbackInfo* ci = &templateBuffer->ipfixParser->callbackInfo[n];			if (ci->optionsTemplateDestructionCallbackFunction) ci->optionsTemplateDestructionCallbackFunction(ci->handle, sourceId, bt->optionsTemplateInfo);			}		free(bt->optionsTemplateInfo);		} else	if (bt->setID == IPFIX_SetId_DataTemplate) {		free(bt->dataTemplateInfo->fieldInfo);		free(bt->dataTemplateInfo->dataInfo);		free(bt->dataTemplateInfo->data);		/* Invoke all registered callback functions */		int n;				for (n = 0; n < templateBuffer->ipfixParser->callbackCount; n++) {			CallbackInfo* ci = &templateBuffer->ipfixParser->callbackInfo[n];			if (ci->dataTemplateDestructionCallbackFunction) ci->dataTemplateDestructionCallbackFunction(ci->handle, sourceId, bt->dataTemplateInfo);			}		free(bt->dataTemplateInfo);		} else {		fatalf("Unknown template type requested to be freed: %d", bt->setID);		}	free(bt);	}