bu5hm4n pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=8f7a76a43145e4568a084af8d40817853bc8e44f

commit 8f7a76a43145e4568a084af8d40817853bc8e44f
Author: Marcel Hollerbach <[email protected]>
Date:   Tue Mar 24 13:22:16 2020 +0100

    eo: do not allocate too much memory
    
    when handoverwriting function on a object, only existing API can be
    overwritten, but not newer ones. Thats why its enough to pass the size
    of the klass, and not the size of the globally defined classes.
    
    Reviewed-by: Stefan Schmidt <[email protected]>
    Differential Revision: https://phab.enlightenment.org/D11571
---
 src/lib/eo/eo.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c
index 7d8c613502..5a781d3d86 100644
--- a/src/lib/eo/eo.c
+++ b/src/lib/eo/eo.c
@@ -144,6 +144,19 @@ _vtable_alloc(unsigned long n, size_t elem)
    return calloc(n, elem);
 }
 #endif
+
+
+/**
+ * This inits the vtable with a given size
+ */
+static void
+_vtable_init_size(Eo_Vtable *vtable, unsigned int size)
+{
+   //we assume here that _eo_classes_last_id was called before
+   vtable->size = size;
+   vtable->chain = _vtable_alloc(vtable->size, sizeof(Eo_Vtable_Node));
+}
+
 /**
  * This inits the vtable wit hthe current size of allocated tables
  */
@@ -151,8 +164,7 @@ static void
 _vtable_init(Eo_Vtable *vtable)
 {
    //we assume here that _eo_classes_last_id was called before
-   vtable->size = _eo_classes_last_id;
-   vtable->chain = _vtable_alloc(vtable->size, sizeof(Eo_Vtable_Node));
+   _vtable_init_size(vtable, _eo_classes_last_id);
 }
 
 /**
@@ -1824,7 +1836,7 @@ efl_object_override(Eo *eo_id, const Efl_Object_Ops *ops)
         if (!vtable)
           {
              vtable = calloc(1, sizeof(*vtable));
-             _vtable_init(vtable);
+             _vtable_init_size(vtable, obj->klass->vtable.size);
              _vtable_take_over(vtable, &obj->klass->vtable);
           }
 

-- 


Reply via email to