Commit bac0648a2f283e5765a452b62cea685c2850a159

Thomas de Grivel 2023-09-25T21:37:06

integer arrays

diff --git a/libc3/array.c b/libc3/array.c
index 8d16938..155bc10 100644
--- a/libc3/array.c
+++ b/libc3/array.c
@@ -176,17 +176,18 @@ void * array_data (const s_array *a, const uw *address)
 s_tag * array_data_tag (s_tag *a, const s_tag *address, s_tag *dest)
 {
   void *a_data;
+  f_copy copy;
   void *dest_data;
-  sw size;
   assert(a->type == TAG_ARRAY);
   assert(address->type == TAG_ARRAY);
   if ((a_data = array_data(&a->data.array,
                            address->data.array.data))) {
     tag_init(dest);
+    copy = array_type_to_copy(a->data.array.type);
     dest->type = array_type_to_tag_type(a->data.array.type);
     dest_data = tag_to_pointer(dest, dest->type);
-    size = tag_type_size(dest->type);
-    memcpy(dest_data, a_data, size);
+    if (copy(a_data, dest_data) != dest_data)
+      return NULL;
     return dest;
   }
   return NULL;