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)
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)
144 return calloc(n, elem); 144 return calloc(n, elem);
145} 145}
146#endif 146#endif
147
148
149/**
150 * This inits the vtable with a given size
151 */
152static void
153_vtable_init_size(Eo_Vtable *vtable, unsigned int size)
154{
155 //we assume here that _eo_classes_last_id was called before
156 vtable->size = size;
157 vtable->chain = _vtable_alloc(vtable->size, sizeof(Eo_Vtable_Node));
158}
159
147/** 160/**
148 * This inits the vtable wit hthe current size of allocated tables 161 * This inits the vtable wit hthe current size of allocated tables
149 */ 162 */
@@ -151,8 +164,7 @@ static void
151_vtable_init(Eo_Vtable *vtable) 164_vtable_init(Eo_Vtable *vtable)
152{ 165{
153 //we assume here that _eo_classes_last_id was called before 166 //we assume here that _eo_classes_last_id was called before
154 vtable->size = _eo_classes_last_id; 167 _vtable_init_size(vtable, _eo_classes_last_id);
155 vtable->chain = _vtable_alloc(vtable->size, sizeof(Eo_Vtable_Node));
156} 168}
157 169
158/** 170/**
@@ -1824,7 +1836,7 @@ efl_object_override(Eo *eo_id, const Efl_Object_Ops *ops)
1824 if (!vtable) 1836 if (!vtable)
1825 { 1837 {
1826 vtable = calloc(1, sizeof(*vtable)); 1838 vtable = calloc(1, sizeof(*vtable));
1827 _vtable_init(vtable); 1839 _vtable_init_size(vtable, obj->klass->vtable.size);
1828 _vtable_take_over(vtable, &obj->klass->vtable); 1840 _vtable_take_over(vtable, &obj->klass->vtable);
1829 } 1841 }
1830 1842