Selaa lähdekoodia

Corrected some errors, found during testing

jos.itemis@gmail.com 14 vuotta sitten
vanhempi
commit
0cf6136f9b

+ 0 - 2
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/StatemachineBaseC.xpt

@@ -36,8 +36,6 @@ void statemachineBase_init_staticData(StatemachineBase* handle, uint32_t* static
 void statemachineBase_exit(StatemachineBase* handle) {
 	if (!handle->isStaticData)
 		free(handle->state);
-	if (handle->timer)
-		timer_exit(handle->timer);
 }
 
 uint32_t statemachineBase_getState(StatemachineBase* handle, uint16_t pos)

+ 12 - 0
plugins/org.yakindu.sct.generator.c/src/org/yakindu/sct/generator/c/templates/Statemachine_cyC.xpt

@@ -27,6 +27,10 @@ void statemachine_cy_init(Statemachine_cy* handle, uint16_t maxStates,
 	/* This is only a place for the pointers to the actual Events */
 	handle->eventList = malloc(sizeof(_Event*) * maxEvents);
 
+	//memset(); <- do we have string.h?
+	for (i=0; i<maxEvents; ++i)
+		handle->eventList[i] = 0;
+
 	/* eventPool must be initialized at this point */
 	handle->eventPool = eventPool;
 
@@ -70,6 +74,14 @@ void statemachine_cy_runCycle(Statemachine_cy* handle) {
 	/* call internal cycle */
 	statemachine_cy__runCycle(handle);
 
+	/* delete all events */
+	for (i=0; i<handle->eventSet.maxEvents; ++i) {
+		if (eventSet_check(&handle->eventSet, i)) {
+			eventPool_freeEvent(handle->eventPool, handle->eventList[i]);
+			handle->eventList[i] = 0;
+		}
+	}
+
 	/* cleanup all events */
 	eventSet_clean(&handle->eventSet);