Commit 333353eabc63a7d84a20ed7e55f2f6c4e4eb5fb6

Thomas de Grivel 2024-07-31T19:57:17

wip httpd

diff --git a/libkc3/buf.c b/libkc3/buf.c
index b87a86a..ee09959 100644
--- a/libkc3/buf.c
+++ b/libkc3/buf.c
@@ -238,6 +238,15 @@ s_buf * buf_init_alloc (s_buf *buf, uw size)
   return buf_init(buf, true, size, p);
 }
 
+s_buf * buf_init_copy (s_buf *buf, const s_buf *src)
+{
+  if (buf != src) {
+    *buf = *src;
+    buf->free = false;
+  }
+  return buf;
+}
+
 s_buf * buf_init_str (s_buf *buf, bool p_free, s_str *p)
 {
   s_buf tmp = {0};
diff --git a/libkc3/buf.h b/libkc3/buf.h
index f52e664..c4cfc5f 100644
--- a/libkc3/buf.h
+++ b/libkc3/buf.h
@@ -30,6 +30,7 @@ void    buf_clean (s_buf *buf);
 s_buf * buf_init (s_buf *buf, bool p_free, uw size, char *p);
 s_buf * buf_init_1 (s_buf *buf, bool p_free, char *p);
 s_buf * buf_init_alloc (s_buf *buf, uw size);
+s_buf * buf_init_copy (s_buf *buf, const s_buf *src);
 s_buf * buf_init_str (s_buf *buf, bool free, s_str *p);
 s_buf * buf_init_str_copy (s_buf *buf, const s_str *str);
 
diff --git a/libkc3/data.c b/libkc3/data.c
index 8437ae6..18896c7 100644
--- a/libkc3/data.c
+++ b/libkc3/data.c
@@ -600,6 +600,8 @@ void * data_init_copy (const s_sym *type, void *data, const void *src)
     return array_init_copy(data, src);
   if (type == &g_sym_Bool)
     return bool_init_copy(data, src);
+  if (type == &g_sym_Buf)
+    return buf_init_copy(data, src);
   if (type == &g_sym_Call)
     return call_init_copy(data, src);
   if (type == &g_sym_Cfn)
diff --git a/libkc3/sym.c b/libkc3/sym.c
index 6d12f4f..7514633 100644
--- a/libkc3/sym.c
+++ b/libkc3/sym.c
@@ -31,6 +31,7 @@ const s_sym g_sym__plus           = {{{NULL},  1, {"+"}}};
 const s_sym g_sym_Array           = {{{NULL},  5, {"Array"}}};
 const s_sym g_sym_Block           = {{{NULL},  5, {"Block"}}};
 const s_sym g_sym_Bool            = {{{NULL},  4, {"Bool"}}};
+const s_sym g_sym_Buf             = {{{NULL},  3, {"Buf"}}};
 const s_sym g_sym_Call            = {{{NULL},  4, {"Call"}}};
 const s_sym g_sym_Cfn             = {{{NULL},  3, {"Cfn"}}};
 const s_sym g_sym_Character       = {{{NULL},  9, {"Character"}}};
@@ -325,6 +326,7 @@ void sym_init_g_sym (void)
   sym_register(&g_sym_Array, NULL);
   sym_register(&g_sym_Block, NULL);
   sym_register(&g_sym_Bool, NULL);
+  sym_register(&g_sym_Buf, NULL);
   sym_register(&g_sym_Call, NULL);
   sym_register(&g_sym_Cfn, NULL);
   sym_register(&g_sym_Character, NULL);
diff --git a/libkc3/sym.h b/libkc3/sym.h
index 8541efe..d2be769 100644
--- a/libkc3/sym.h
+++ b/libkc3/sym.h
@@ -35,6 +35,7 @@ extern const s_sym g_sym__plus;
 extern const s_sym g_sym_Array;
 extern const s_sym g_sym_Block;
 extern const s_sym g_sym_Bool;
+extern const s_sym g_sym_Buf;
 extern const s_sym g_sym_Call;
 extern const s_sym g_sym_Cfn;
 extern const s_sym g_sym_Character;