This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch edje-vector-intergration
in repository efl.

View the commit online.

commit 15d66e155db1451c2868a38ced84e436c90f9d51
Author: [email protected] <[email protected]>
AuthorDate: Tue Apr 28 09:55:45 2026 -0600

    edje: free vector_dir on .edj unload (Phase 1.4)
    
    Implement missing cleanup in _edje_file_free to prevent leaks when
    .edj files are unloaded. The vector_dir directory, its trees, and the
    class-name index are now freed following the image_dir pattern: walk
    contents (free each tree's subtree, then arrays; under free_strings,
    stringshare-del class names), then free the struct.
    
    A supporting refactor splits _edje_vg_tree_free into _free_fields
    (cleanup inner node tree without freeing the struct) and the original
    _free_fields-then-free pattern. The split is necessary because trees
    in vector_dir->trees are inline array elements — their inner
    allocations need releasing but the array slot itself is freed as part
    of the array, not individually.
    
    Writer side is intentionally inactive: with no Phase 2 parser yet,
    vector_dir stays NULL on encode and decode, so existing themes
    round-trip unchanged.
    
    Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
---
 src/lib/edje/edje_load.c    | 24 ++++++++++++++++++++++++
 src/lib/edje/edje_vg_tree.c |  9 ++++++++-
 src/lib/edje/edje_vg_tree.h |  5 +++++
 3 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/src/lib/edje/edje_load.c b/src/lib/edje/edje_load.c
index 7d4d092eee..972a5f2f38 100644
--- a/src/lib/edje/edje_load.c
+++ b/src/lib/edje/edje_load.c
@@ -1,4 +1,5 @@
 #include "edje_private.h"
+#include "edje_vg_tree.h"
 
 typedef struct _Edje_Table_Items Edje_Table_Items;
 struct _Edje_Table_Items
@@ -2201,6 +2202,29 @@ _edje_file_free(Edje_File *edf)
         free(edf->image_dir->vectors);
         free(edf->image_dir);
      }
+   if (edf->vector_dir)
+     {
+        unsigned int i;
+
+        /* trees is a flat array of Edje_Vg_Tree structs (not pointers).
+         * Free each tree's interior heap allocations (root node tree),
+         * then free the array itself. */
+        for (i = 0; i < edf->vector_dir->trees_count; i++)
+          _edje_vg_tree_free_fields(&edf->vector_dir->trees[i]);
+        free(edf->vector_dir->trees);
+
+        /* class_names is a flat array of stringshare strings (Eet decodes
+         * EET_T_STRING via file descriptors using eina_stringshare_add).
+         * Guard with free_strings to match the pattern used by all other dirs. */
+        if (edf->free_strings)
+          {
+             for (i = 0; i < edf->vector_dir->class_names_count; i++)
+               eina_stringshare_del(edf->vector_dir->class_names[i]);
+          }
+        free(edf->vector_dir->class_names);
+        free(edf->vector_dir);
+        edf->vector_dir = NULL;
+     }
    if (edf->sound_dir)
      {
         unsigned int i;
diff --git a/src/lib/edje/edje_vg_tree.c b/src/lib/edje/edje_vg_tree.c
index 464beb2d18..489dd1e467 100644
--- a/src/lib/edje/edje_vg_tree.c
+++ b/src/lib/edje/edje_vg_tree.c
@@ -202,11 +202,18 @@ _node_free(Edje_Vg_Node *n)
 }
 
 EAPI void
-_edje_vg_tree_free(Edje_Vg_Tree *t)
+_edje_vg_tree_free_fields(Edje_Vg_Tree *t)
 {
    if (!t) return;
    _node_free(t->root);
    t->root = NULL;
+}
+
+EAPI void
+_edje_vg_tree_free(Edje_Vg_Tree *t)
+{
+   if (!t) return;
+   _edje_vg_tree_free_fields(t);
    free(t);
 }
 
diff --git a/src/lib/edje/edje_vg_tree.h b/src/lib/edje/edje_vg_tree.h
index 5c1b598258..97666970f9 100644
--- a/src/lib/edje/edje_vg_tree.h
+++ b/src/lib/edje/edje_vg_tree.h
@@ -20,6 +20,11 @@ EAPI Edje_Vg_Tree        *_edje_vg_tree_new_for_test(void);
 EAPI Eina_Bool            _edje_vg_tree_equal(const Edje_Vg_Tree *a,
                                                const Edje_Vg_Tree *b);
 
+/* Free interior heap allocations (root node tree) without freeing t itself.
+ * Use when t is embedded in a flat array rather than individually heap-alloc'd.
+ * Safe to call with NULL. */
+EAPI void                 _edje_vg_tree_free_fields(Edje_Vg_Tree *t);
+
 /* Recursive free.  Safe to call with NULL. */
 EAPI void                 _edje_vg_tree_free(Edje_Vg_Tree *t);
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to