#include <stdio.h>
+#include <string.h>
#include "feierabend.h"
#include "time_format.h"
#include "validate.h"
time_t _set_time(time_t value, struct tm* tm_value, int hour, int minutes)
{
- time(&value);
+ value = time(NULL);
- tm_value = localtime(&value);
+ const struct tm* tm_tmp = localtime(&value);
+ memcpy(tm_value, tm_tmp, sizeof(struct tm));
tm_value->tm_hour = hour;
tm_value->tm_min = minutes;
fabend->now = 0;
fabend->begin = 0;
fabend->worktime = 0;
- fabend->now_tm = malloc(sizeof(struct tm));
+ fabend->now_tm = NULL;
fabend->begin_tm = malloc(sizeof(struct tm));
- fabend->work_end_tm = malloc(sizeof(struct tm));
- fabend->max_work_end_tm = malloc(sizeof(struct tm));
+ fabend->work_end_tm = NULL;
+ fabend->max_work_end_tm = NULL;
return fabend;
}
void feierabend_free(feierabend* fabend)
{
- free(fabend->now_tm);
- fabend->now_tm = NULL;
free(fabend->begin_tm);
fabend->begin_tm = NULL;
- free(fabend->work_end_tm);
- fabend->work_end_tm = NULL;
- free(fabend->max_work_end_tm);
- fabend->max_work_end_tm = NULL;
}
#endif
\ No newline at end of file