Commit 54a05ab13a6a12f491bf90e5ed13abc830e5ca59

Thomas de Grivel 2024-11-07T13:09:56

wip fixing time init copy

diff --git a/libkc3/env.c b/libkc3/env.c
index e97a0d1..338c9a7 100644
--- a/libkc3/env.c
+++ b/libkc3/env.c
@@ -1284,7 +1284,7 @@ bool env_eval_equal_time (s_env *env, bool macro, const s_time *a,
   if (! env_eval_equal_tag(env, macro, a2, b2, tmp_tag)) {
     return false;
   }
-  if (! env_eval_equal_tag(env, macro, a2 + 1, b2 + 1, tmp.tag + 1)) {
+  if (! env_eval_equal_tag(env, macro, a2 + 1, b2 + 1, tmp_tag + 1)) {
     tag_clean(tmp_tag);
     return false;
   }
diff --git a/libkc3/time.c b/libkc3/time.c
index 7779f66..cade266 100644
--- a/libkc3/time.c
+++ b/libkc3/time.c
@@ -14,6 +14,8 @@
 #include "alloc.h"
 #include "assert.h"
 #include "str.h"
+#include "sw.h"
+#include "sym.h"
 #include "tag.h"
 #include "time.h"
 
@@ -65,21 +67,13 @@ s_time * time_init_add (s_time *time, const s_time *a, const s_time *b)
 
 s_time * time_init_copy (s_time *time, const s_time *src)
 {
+  const s_sym *sym_Sw = &g_sym_Sw;
   s_time tmp = {0};
   if (src->tag) {
-    if (! time_allocate(&tmp))
+    if (! sw_init_cast(&tmp.tv_sec, &sym_Sw, src->tag))
       return NULL;
-    if (! tag_init_copy(tmp.tag, src->tag)) {
-      free(tmp.tag);
+    if (! sw_init_cast(&tmp.tv_nsec, &sym_Sw, src->tag + 1))
       return NULL;
-    }
-    if (! tag_init_copy(tmp.tag + 1, src->tag + 1)) {
-      tag_clean(tmp.tag);
-      free(tmp.tag);
-      return NULL;
-    }
-    *time = tmp;
-    return time;
   }
   else {
     tmp.tv_sec = src->tv_sec;