time(¤t_time);
current = localtime(¤t_time);
+
+ if(current == NULL)
+ {
+ printf("ERROR; Getting local time fails\n");
+ return 0;
+ }
+
midnight = (struct tm* )malloc(sizeof(struct tm));
+
+ if(midnight == NULL)
+ {
+ printf("ERROR; Memory allocation fails\n");
+ return 0;
+ }
+
memcpy(midnight, current, sizeof(struct tm));
midnight->tm_hour = 0;
delayed_time = getRelativeSecondsOfDayofweek(current->tm_wday, tp->tm_wday) - delayed_time;
delayed_time = delayed_time + getSeconds(tp);
+ free(midnight);
+
return delayed_time;
}
void unregisterTimer(int idx)
{
- if( 0 <= idx && idx <= TIMEOUTS)
+ if( 0 <= idx && idx < TIMEOUTS)
timeout_list[idx].timeout_state = TIMEOUT_UNUSED;
}
void unregisterTimer(int idx)
{
- if( 0 <= idx && idx <= TIMEOUTS)
+ if( 0 <= idx && idx < TIMEOUTS)
timeout_list[idx].timeout_state = TIMEOUT_UNUSED;
}