]> Kevux Git Server - fll/commitdiff
Bugfix: Stop using f_memory_array_append_all() for an array of IKI data.
authorKevin Day <thekevinday@gmail.com>
Sat, 12 Aug 2023 03:29:35 +0000 (22:29 -0500)
committerKevin Day <thekevinday@gmail.com>
Sat, 12 Aug 2023 03:29:35 +0000 (22:29 -0500)
There is some logic mistake, structural mistake, design mistake, or an oversight.
Just do not use it for now and instead use a traditional for loop.

I may get rid of f_memory_array_append_all() in the future or I may spend time investigating what my mistake is in this use case.

level_0/f_iki/c/iki/private-data.c

index d24edb40e184149933186f8ca23fbf71d6d1ff08..b9ab34ab8c9c97c79a1303848c0cb70e826c3187 100644 (file)
@@ -46,8 +46,11 @@ extern "C" {
     }
 
     if (source.delimits.used) {
-      status = f_memory_array_append_all((const void *) &source.delimits.array, source.delimits.used, sizeof(f_number_unsigned_t), (void **) &destination->array[destination->used].delimits.array, &destination->array[destination->used].delimits.used, &destination->array[destination->used].delimits.size);
-      if (F_status_is_error(status)) return status;
+      for (f_number_unsigned_t i = 0; i < source.delimits.used; ++i) {
+
+        status = f_memory_array_append(source.delimits.array + i, sizeof(f_number_unsigned_t), (void **) &destination->array[destination->used].delimits.array, &destination->array[destination->used].delimits.used, &destination->array[destination->used].delimits.size);
+        if (F_status_is_error(status)) return status;
+      } // for
     }
 
     if (source.variable.used) {
@@ -72,33 +75,38 @@ extern "C" {
     f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_iki_data_t), (void **) &destination->array, &destination->used, &destination->size);
     if (F_status_is_error(status)) return status;
 
-    for (f_number_unsigned_t i = 0; i < source.used; ++i, ++destination->used) {
+    {
+      f_number_unsigned_t j = 0;
 
-      destination->array[destination->used].content.used = 0;
-      destination->array[destination->used].delimits.used = 0;
-      destination->array[destination->used].variable.used = 0;
-      destination->array[destination->used].vocabulary.used = 0;
+      for (f_number_unsigned_t i = 0; i < source.used; ++i, ++destination->used) {
 
-      if (source.array[i].content.used) {
-        status = f_string_ranges_append_all(source.array[i].content, &destination->array[destination->used].content);
-        if (F_status_is_error(status)) return status;
-      }
+        destination->array[destination->used].content.used = 0;
+        destination->array[destination->used].delimits.used = 0;
+        destination->array[destination->used].variable.used = 0;
+        destination->array[destination->used].vocabulary.used = 0;
 
-      if (source.array[i].delimits.used) {
-        status = f_memory_array_append_all((const void *) &source.array[i].delimits.array, source.array[i].delimits.used, sizeof(f_number_unsigned_t), (void **) &destination->array[destination->used].delimits.array, &destination->array[destination->used].delimits.used, &destination->array[destination->used].delimits.size);
-        if (F_status_is_error(status)) return status;
-      }
+        if (source.array[i].content.used) {
+          status = f_string_ranges_append_all(source.array[i].content, &destination->array[destination->used].content);
+          if (F_status_is_error(status)) return status;
+        }
 
-      if (source.array[i].variable.used) {
-        status = f_string_ranges_append_all(source.array[i].variable, &destination->array[destination->used].variable);
-        if (F_status_is_error(status)) return status;
-      }
+        for (j = 0; j < source.array[i].delimits.used; ++j) {
 
-      if (source.array[i].vocabulary.used) {
-        status = f_string_ranges_append_all(source.array[i].vocabulary, &destination->array[destination->used].vocabulary);
-        if (F_status_is_error(status)) return status;
-      }
-    } // for
+          status = f_memory_array_append(source.array[i].delimits.array + j, sizeof(f_number_unsigned_t), (void **) &destination->array[destination->used].delimits.array, &destination->array[destination->used].delimits.used, &destination->array[destination->used].delimits.size);
+          if (F_status_is_error(status)) return status;
+        } // for
+
+        if (source.array[i].variable.used) {
+          status = f_string_ranges_append_all(source.array[i].variable, &destination->array[destination->used].variable);
+          if (F_status_is_error(status)) return status;
+        }
+
+        if (source.array[i].vocabulary.used) {
+          status = f_string_ranges_append_all(source.array[i].vocabulary, &destination->array[destination->used].vocabulary);
+          if (F_status_is_error(status)) return status;
+        }
+      } // for
+    }
 
     return F_none;
   }