]> gitweb.hhaalo.de Git - feierabend.git/commitdiff
fix copy static pointer value
authorBastian Dehn <hhaalo@arcor.de>
Tue, 10 Feb 2026 18:35:48 +0000 (19:35 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Tue, 10 Feb 2026 18:35:48 +0000 (19:35 +0100)
src/feierabend.c
src/feierabend.h

index 5d2ebdd06d240af3510c4ff6984ac77bcc197d15..bec0feefa80a9ccef8a32041a3d3056206b9cada 100644 (file)
@@ -1,4 +1,5 @@
 #include <stdio.h>
+#include <string.h>
 #include "feierabend.h"
 #include "time_format.h"
 #include "validate.h"
@@ -26,9 +27,10 @@ void _print_german_long_date(const struct tm* time_info)
 
 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;
 
index 61e17abb437b4d6c37e96809cd92c48ac05121ea..f3ca90c6adbb20c605c7da4dcfe886246f877e05 100644 (file)
@@ -25,24 +25,18 @@ feierabend* feierabend_init()
        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