Commit 696cf3d00d862f752c9d1faba335b4b435c68bf3

Thomas de Grivel 2024-09-29T11:16:58

Facts.env_facts

diff --git a/lib/kc3/0.1/facts.kc3 b/lib/kc3/0.1/facts.kc3
index 0fcb9f5..0f0b358 100644
--- a/lib/kc3/0.1/facts.kc3
+++ b/lib/kc3/0.1/facts.kc3
@@ -16,8 +16,6 @@ defmodule Facts do
 
   def cast = cfn Tag "tag_init_cast_struct" (Result, Sym, Tag)
 
-  def clean = cfn Void "facts_clean" (Facts)
-
   def collect_with_tags = cfn Tag "kc3_facts_collect_with_tags" (Facts,
     Tag, Tag, Tag, Fn, Result)
 
@@ -26,7 +24,7 @@ defmodule Facts do
   def delete = cfn Void "facts_delete" (Facts)
 
   # env_facts() -> facts
-  def env_facts = cfn Ptr "kc3_env_facts" ()
+  def env_facts = cfn Ptr "kc3_env_facts" (Result)
 
   # with_tags(facts, subject, predicate, object,
   #           fn (fact) {result}) -> result
diff --git a/libkc3/kc3.c b/libkc3/kc3.c
index b267d80..7b0184d 100644
--- a/libkc3/kc3.c
+++ b/libkc3/kc3.c
@@ -165,9 +165,10 @@ void ** kc3_dlopen (const s_str *path, void **dest)
   return dest;
 }
 
-s_facts * kc3_env_facts (void)
+s_facts ** kc3_env_facts (s_facts **dest)
 {
-  return &g_kc3_env.facts;
+  *dest = &g_kc3_env.facts;
+  return dest;
 }
 
 sw kc3_errno (void)
diff --git a/libkc3/kc3_main.h b/libkc3/kc3_main.h
index 7007d69..d35179c 100644
--- a/libkc3/kc3_main.h
+++ b/libkc3/kc3_main.h
@@ -63,7 +63,7 @@ s_tag *      kc3_defoperator (const s_sym **name, const s_sym **sym,
                               s_tag *dest);
 s_tag *      kc3_defstruct (const s_list * const *spec, s_tag *dest);
 void **      kc3_dlopen (const s_str *path, void **dest);
-s_facts *    kc3_env_facts (void);
+s_facts **   kc3_env_facts (s_facts **dest);
 sw           kc3_errno (void);
 void         kc3_exit (sw code);
 s_tag *      kc3_facts_collect_with_tags (s_facts *facts,