From a5742a341c6d35cac8ad01665c051d5261ce219c Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Mon, 23 Apr 2012 08:09:45 +0000 Subject: [PATCH] Eobj: Allocate the data blob at the end of the object. This replaces the obj->data_blob pointer. Hopefully will be better. SVN revision: 70405 --- legacy/eobj/lib/eobj.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/legacy/eobj/lib/eobj.c b/legacy/eobj/lib/eobj.c index f66c4cb4f7..a5bb115efb 100644 --- a/legacy/eobj/lib/eobj.c +++ b/legacy/eobj/lib/eobj.c @@ -24,7 +24,6 @@ struct _Eobj { EINA_MAGIC Eobj *parent; const Eobj_Class *klass; - void *data_blob; int refcount; #ifndef NDEBUG Eina_Inlist *xrefs; @@ -848,15 +847,14 @@ eobj_add(const Eobj_Class *klass, Eobj *parent) return NULL; } - Eobj *obj = calloc(1, sizeof(*obj)); + Eobj *obj = calloc(1, EOBJ_ALIGN_SIZE(sizeof(*obj)) + + (klass->data_offset + EOBJ_ALIGN_SIZE(klass->desc->data_size)) + + klass->extn_data_size); obj->klass = klass; obj->parent = parent; obj->refcount++; - obj->data_blob = calloc(1, klass->data_offset + klass->desc->data_size + - klass->extn_data_size); - _eobj_kls_itr_init(obj, EOBJ_NOOP); eobj_constructor_error_unset(obj); @@ -1012,9 +1010,6 @@ eobj_unref(Eobj *obj) _eobj_callback_remove_all(obj); - if (obj->data_blob) - free(obj->data_blob); - free(obj); } } @@ -1160,13 +1155,15 @@ eobj_data_get(const Eobj *obj, const Eobj_Class *klass) while (doff_itr->klass) { if (doff_itr->klass == klass) - return ((char *) obj->data_blob) + doff_itr->offset; + return ((char *) obj) + EOBJ_ALIGN_SIZE(sizeof(*obj)) + + doff_itr->offset; doff_itr++; } } else { - return ((char *) obj->data_blob) + klass->data_offset; + return ((char *) obj) + EOBJ_ALIGN_SIZE(sizeof(*obj)) + + klass->data_offset; } }