ht->template = 0; if (ht->dataTemplate->dataCount == 0) { ht->template = (TemplateInfo*)malloc(sizeof(TemplateInfo)); ht->template->fieldCount = ht->dataTemplate->fieldCount; ht->template->fieldInfo = ht->dataTemplate->fieldInfo; ht->template->userData = ht->dataTemplate->userData; }
Hashtable* createHashtable(Rule* rule, uint16_t minBufferTime, uint16_t maxBufferTime) {	int i;	int dataLength = 0; /**< length in bytes of the @c ht->data field */		Hashtable* ht = (Hashtable*)malloc(sizeof(Hashtable));	ht->callbackCount = 0;	ht->callbackInfo = 0;	ht->minBufferTime = minBufferTime;	ht->maxBufferTime = maxBufferTime;		ht->bucketCount = HASHTABLE_SIZE;	for (i = 0; i < ht->bucketCount; i++) ht->bucket[i] = NULL;		ht->dataTemplate = (DataTemplateInfo*)malloc(sizeof(DataTemplateInfo));	ht->dataTemplate->fieldCount = 0;	ht->dataTemplate->fieldInfo = NULL;	ht->fieldLength = 0;	ht->dataTemplate->dataCount = 0;	ht->dataTemplate->dataInfo = NULL;	ht->dataTemplate->data = NULL;	ht->dataTemplate->userData = NULL;		ht->fieldModifier = (FieldModifier*)malloc(rule->fieldCount * sizeof(FieldModifier));		for (i = 0; i < rule->fieldCount; i++) {		RuleField* rf = rule->field[i];				if (rf->pattern != NULL) {			/* create new fixed-data field containing pattern */			ht->dataTemplate->dataCount++;			ht->dataTemplate->dataInfo = realloc(ht->dataTemplate->dataInfo, sizeof(FieldInfo) * ht->dataTemplate->dataCount);			FieldInfo* fi = &ht->dataTemplate->dataInfo[ht->dataTemplate->dataCount - 1];			fi->type = rf->type;			fi->offset = dataLength;			dataLength += fi->type.length;			ht->dataTemplate->data = realloc(ht->dataTemplate->data, dataLength);			memcpy(ht->dataTemplate->data + fi->offset, rf->pattern, fi->type.length);			}				if (rf->modifier != FIELD_MODIFIER_DISCARD) {			/* define new data field with RuleField's type */			ht->dataTemplate->fieldCount++;			ht->dataTemplate->fieldInfo = realloc(ht->dataTemplate->fieldInfo, sizeof(FieldInfo) * ht->dataTemplate->fieldCount);			FieldInfo* fi = &ht->dataTemplate->fieldInfo[ht->dataTemplate->fieldCount - 1];			fi->type = rf->type;			fi->offset = ht->fieldLength;			ht->fieldLength += fi->type.length;			ht->fieldModifier[ht->dataTemplate->fieldCount - 1] = rf->modifier;			}					}		/* Informing the Exporter of a new Data Template is done when adding the callback functions */		return ht;	}