mirror of
https://github.com/netfun2000/lcd4linux.git
synced 2026-02-27 09:44:34 +08:00
Ticket #284
git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@1193 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
This commit is contained in:
+1
-1
@@ -1 +1 @@
|
||||
#define SVN_VERSION "1192"
|
||||
#define SVN_VERSION "1193"
|
||||
|
||||
+18
-7
@@ -75,10 +75,10 @@
|
||||
|
||||
/* structure for storing all relevant data of a single timer group */
|
||||
typedef struct TIMER_GROUP {
|
||||
/* group's triggering interval in milliseconds;
|
||||
/* pointer to the group's triggering interval in milliseconds;
|
||||
this will be used to identify a specific timer group and also
|
||||
as callback data for the underlying generic timer */
|
||||
int interval;
|
||||
int *interval;
|
||||
|
||||
/* marks timer group as being active (so it will get processed) or
|
||||
inactive (which means the timer group has been deleted and its
|
||||
@@ -144,7 +144,7 @@ int timer_group_exists(const int interval)
|
||||
if (TimerGroups[group].active == TIMER_INACTIVE)
|
||||
continue;
|
||||
|
||||
if (TimerGroups[group].interval == interval) {
|
||||
if (*TimerGroups[group].interval == interval) {
|
||||
/* matching timer group found, so signal success by returning
|
||||
a value of 1 */
|
||||
return 1;
|
||||
@@ -185,6 +185,7 @@ int timer_add_group(const int interval)
|
||||
if (TimerGroups[group].active == TIMER_INACTIVE) {
|
||||
/* we've just found one, so let's reuse it ("group" holds its
|
||||
ID) by breaking the loop */
|
||||
debug("Reusing Timergroup %i", group);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -195,15 +196,21 @@ int timer_add_group(const int interval)
|
||||
TIMER_GROUP *tmp;
|
||||
|
||||
if ((tmp = realloc(TimerGroups, (nTimerGroups + 1) * sizeof(*TimerGroups))) == NULL) {
|
||||
error("Error expanding TimerGroups");
|
||||
/* signal unsuccessful timer group creation */
|
||||
return -1;
|
||||
}
|
||||
TimerGroups = tmp;
|
||||
nTimerGroups++;
|
||||
|
||||
if ((TimerGroups[group].interval = malloc(sizeof(int))) == NULL) {
|
||||
/* signal unsuccessful timer group creation */
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* initialize timer group's interval */
|
||||
TimerGroups[group].interval = interval;
|
||||
*TimerGroups[group].interval = interval;
|
||||
|
||||
/* set timer group to active so that it is processed and not
|
||||
overwritten by the memory optimization routine above */
|
||||
@@ -211,7 +218,7 @@ int timer_add_group(const int interval)
|
||||
|
||||
/* finally, request a generic timer that calls this group and
|
||||
signal success or failure */
|
||||
return timer_add(timer_process_group, &TimerGroups[group].interval, interval, 0);
|
||||
return timer_add(timer_process_group, TimerGroups[group].interval, interval, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -255,7 +262,7 @@ int timer_remove_group(const int interval)
|
||||
if (TimerGroups[group].active == TIMER_INACTIVE)
|
||||
continue;
|
||||
|
||||
if (TimerGroups[group].interval == interval) {
|
||||
if (*TimerGroups[group].interval == interval) {
|
||||
/* we have found the timer group slot, so mark it as being
|
||||
inactive; we will not actually delete the slot, so its
|
||||
allocated memory may be re-used */
|
||||
@@ -504,7 +511,11 @@ void timer_exit_group(void)
|
||||
/* loop through all timer groups and remove them one by one */
|
||||
for (group = 0; group < nTimerGroups; group++) {
|
||||
/* remove generic timer */
|
||||
timer_remove(timer_process_group, &TimerGroups[group].interval);
|
||||
timer_remove(timer_process_group, TimerGroups[group].interval);
|
||||
|
||||
/* free memory allocated for callback data (i.e. the group's
|
||||
triggering interval in milliseconds) */
|
||||
free(TimerGroups[group].interval);
|
||||
}
|
||||
|
||||
/* reset number of allocated timer groups */
|
||||
|
||||
Reference in New Issue
Block a user