summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2020-03-24 13:22:16 +0100
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2020-03-24 20:41:11 +0100
commit8f7a76a43145e4568a084af8d40817853bc8e44f (patch)
treed1f61f801b165a9cdee83b806b844b7b19643316
parentf4a877d17d62430be1395fa64c9a18f4c43d06cf (diff)
downloadefl-8f7a76a43145e4568a084af8d40817853bc8e44f.tar.gz
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 <stefan@datenfreihafen.org> Differential Revision: https://phab.enlightenment.org/D11571
-rw-r--r--src/lib/eo/eo.c18
1 files 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);
}