static void evas_event_callback_clear(Evas *e);
int _evas_event_counter = 0;
+EVAS_MEMPOOL(_mp_fn);
+EVAS_MEMPOOL(_mp_cb);
+EVAS_MEMPOOL(_mp_pc);
+
void
_evas_post_event_callback_call(Evas *e)
{
{
if (!pc->func((void*)pc->data, e)) skip = 1;
}
- free(pc);
+ EVAS_MEMPOOL_FREE(_mp_pc, pc);
}
_evas_unwalk(e);
}
EINA_LIST_FREE(e->post_events, pc)
{
- free(pc);
+ EVAS_MEMPOOL_FREE(_mp_pc, pc);
}
_evas_unwalk(e);
}
if (fn->delete_me)
{
*list = eina_inlist_remove(*list, EINA_INLIST_GET(fn));
- free(fn);
+ EVAS_MEMPOOL_FREE(_mp_fn, fn);
}
}
}
evas_event_callback_list_post_free(&obj->callbacks->callbacks);
if (!obj->callbacks->callbacks)
{
- free(obj->callbacks);
+ EVAS_MEMPOOL_FREE(_mp_cb, obj->callbacks);
obj->callbacks = NULL;
}
}
evas_event_callback_list_post_free(&e->callbacks->callbacks);
if (!e->callbacks->callbacks)
{
- free(e->callbacks);
+ EVAS_MEMPOOL_FREE(_mp_cb, e->callbacks);
e->callbacks = NULL;
}
}
/* MEM OK */
if (!obj->callbacks) return;
evas_event_callback_list_post_free(&obj->callbacks->callbacks);
- free(obj->callbacks);
+ EVAS_MEMPOOL_FREE(_mp_cb, obj->callbacks);
obj->callbacks = NULL;
}
/* MEM OK */
if (!e->callbacks) return;
evas_event_callback_list_post_free(&e->callbacks->callbacks);
- free(e->callbacks);
+ EVAS_MEMPOOL_FREE(_mp_cb, e->callbacks);
e->callbacks = NULL;
}
if (!func) return;
- fn = evas_mem_calloc(sizeof(Evas_Func_Node));
+ if (!obj->callbacks)
+ {
+ EVAS_MEMPOOL_INIT(_mp_cb, "evas_callbacks", Evas_Callbacks, 512, );
+ obj->callbacks = EVAS_MEMPOOL_ALLOC(_mp_cb, Evas_Callbacks);
+ if (!obj->callbacks) return;
+ EVAS_MEMPOOL_PREP(_mp_cb, obj->callbacks, Evas_Callbacks);
+ }
+
+ EVAS_MEMPOOL_INIT(_mp_fn, "evas_func_node", Evas_Func_Node, 2048, );
+ fn = EVAS_MEMPOOL_ALLOC(_mp_fn, Evas_Func_Node);
if (!fn) return;
+ EVAS_MEMPOOL_PREP(_mp_fn, fn, Evas_Func_Node);
fn->func = func;
fn->data = (void *)data;
fn->type = type;
- if (!obj->callbacks)
- obj->callbacks = evas_mem_calloc(sizeof(Evas_Callbacks));
- if (!obj->callbacks)
- {
- free(fn);
- return;
- }
obj->callbacks->callbacks =
eina_inlist_prepend(obj->callbacks->callbacks, EINA_INLIST_GET(fn));
}
if (!func) return;
- fn = evas_mem_calloc(sizeof(Evas_Func_Node));
+ if (!e->callbacks)
+ {
+ EVAS_MEMPOOL_INIT(_mp_cb, "evas_callbacks", Evas_Callbacks, 512, );
+ e->callbacks = EVAS_MEMPOOL_ALLOC(_mp_cb, Evas_Callbacks);
+ if (!e->callbacks) return;
+ EVAS_MEMPOOL_PREP(_mp_cb, e->callbacks, Evas_Callbacks);
+ }
+
+ EVAS_MEMPOOL_INIT(_mp_fn, "evas_func_node", Evas_Func_Node, 2048, );
+ fn = EVAS_MEMPOOL_ALLOC(_mp_fn, Evas_Func_Node);
if (!fn) return;
+ EVAS_MEMPOOL_PREP(_mp_fn, fn, Evas_Func_Node);
fn->func = func;
fn->data = (void *)data;
fn->type = type;
- if (!e->callbacks)
- e->callbacks = evas_mem_calloc(sizeof(Evas_Callbacks));
- if (!e->callbacks)
- {
- free(fn);
- return;
- }
e->callbacks->callbacks =
eina_inlist_prepend(e->callbacks->callbacks, EINA_INLIST_GET(fn));
}
return;
MAGIC_CHECK_END();
- pc = evas_mem_calloc(sizeof(Evas_Post_Callback));
+ EVAS_MEMPOOL_INIT(_mp_pc, "evas_post_callback", Evas_Post_Callback, 64, );
+ pc = EVAS_MEMPOOL_ALLOC(_mp_pc, Evas_Post_Callback);
if (!pc) return;
+ EVAS_MEMPOOL_PREP(_mp_pc, pc, Evas_Post_Callback);
if (e->delete_me) return;
pc->func = func;
* @{
*/
+EVAS_MEMPOOL(_mp_obj);
+
/**
* Creates a new image object on the given evas.
*
Evas_Object_Image *o;
/* alloc obj private data */
- o = calloc(1, sizeof(Evas_Object_Image));
+ EVAS_MEMPOOL_INIT(_mp_obj, "evas_object_image", Evas_Object_Image, 256, NULL);
+ o = EVAS_MEMPOOL_ALLOC(_mp_obj, Evas_Object_Image);
+ if (!o) return NULL;
+ EVAS_MEMPOOL_PREP(_mp_obj, o, Evas_Object_Image);
o->magic = MAGIC_OBJ_IMAGE;
o->cur.fill.w = 0;
o->cur.fill.h = 0;
o->magic = 0;
EINA_LIST_FREE(o->pixel_updates, r)
eina_rectangle_free(r);
- free(o);
+ EVAS_MEMPOOL_FREE(_mp_obj, o);
}
static void
* @{
*/
+EVAS_MEMPOOL(_mp_obj);
+
/**
* Adds a new evas line object to the given evas.
* @param e The given evas.
Evas_Object_Line *o;
/* alloc obj private data */
- o = calloc(1, sizeof(Evas_Object_Line));
+ EVAS_MEMPOOL_INIT(_mp_obj, "evas_object_line", Evas_Object_Line, 16, NULL);
+ o = EVAS_MEMPOOL_ALLOC(_mp_obj, Evas_Object_Line);
+ if (!o) return NULL;
+ EVAS_MEMPOOL_PREP(_mp_obj, o, Evas_Object_Line);
o->magic = MAGIC_OBJ_LINE;
o->cur.x1 = 0;
o->cur.y1 = 0;
#include "evas_common.h"
#include "evas_private.h"
+EVAS_MEMPOOL(_mp_obj);
+EVAS_MEMPOOL(_mp_sh);
+
static Eina_Inlist *
get_layer_objects(Evas_Layer *l)
{
- if( !l || !l->objects ) return NULL;
-
+ if ((!l) || (!l->objects)) return NULL;
return (EINA_INLIST_GET(l->objects));
}
{
Evas_Object *obj;
- obj = calloc(1, sizeof(Evas_Object));
+ EVAS_MEMPOOL_INIT(_mp_obj, "evas_object", Evas_Object, 512, NULL);
+ obj = EVAS_MEMPOOL_ALLOC(_mp_obj, Evas_Object);
if (!obj) return NULL;
-
+ EVAS_MEMPOOL_PREP(_mp_obj, obj, Evas_Object);
+
obj->magic = MAGIC_OBJ;
obj->cur.scale = 1.0;
obj->prev.scale = 1.0;
free(node);
}
obj->magic = 0;
- if (obj->size_hints) free(obj->size_hints);
- free(obj);
+ if (obj->size_hints)
+ {
+ EVAS_MEMPOOL_FREE(_mp_sh, obj->size_hints);
+ }
+ EVAS_MEMPOOL_FREE(_mp_obj, obj);
}
void
{
if (obj->size_hints) return;
- obj->size_hints = calloc(1, sizeof(Evas_Size_Hints));
+ EVAS_MEMPOOL_INIT(_mp_sh, "evas_size_hints", Evas_Size_Hints, 512, );
+ obj->size_hints = EVAS_MEMPOOL_ALLOC(_mp_sh, Evas_Size_Hints);
+ if (!obj->size_hints) return;
+ EVAS_MEMPOOL_PREP(_mp_sh, obj->size_hints, Evas_Size_Hints);
obj->size_hints->max.w = -1;
obj->size_hints->max.h = -1;
obj->size_hints->align.x = 0.5;
* @{
*/
+EVAS_MEMPOOL(_mp_obj);
+
/**
* Adds a new evas polygon object to the given evas.
* @param e The given evas.
Evas_Object_Polygon *o;
/* alloc obj private data */
- o = calloc(1, sizeof(Evas_Object_Polygon));
+ EVAS_MEMPOOL_INIT(_mp_obj, "evas_object_polygon", Evas_Object_Polygon, 32, NULL);
+ o = EVAS_MEMPOOL_ALLOC(_mp_obj, Evas_Object_Polygon);
+ if (!o) return NULL;
+ EVAS_MEMPOOL_PREP(_mp_obj, o, Evas_Object_Polygon);
o->magic = MAGIC_OBJ_POLYGON;
return o;
}
obj->layer->evas->engine.data.context,
o->engine_data);
o->magic = 0;
- free(o);
+ EVAS_MEMPOOL_FREE(_mp_obj, o);
}
static void
* @{
*/
+EVAS_MEMPOOL(_mp_obj);
+
/**
* Adds a rectangle to the given evas.
* @param e The given evas.
Evas_Object_Rectangle *o;
/* alloc obj private data */
- o = calloc(1, sizeof(Evas_Object_Rectangle));
+ EVAS_MEMPOOL_INIT(_mp_obj, "evas_object_rectangle", Evas_Object_Rectangle, 256, NULL);
+ o = EVAS_MEMPOOL_ALLOC(_mp_obj, Evas_Object_Rectangle);
+ if (!o) return NULL;
+ EVAS_MEMPOOL_PREP(_mp_obj, o, Evas_Object_Rectangle);
o->magic = MAGIC_OBJ_RECTANGLE;
return o;
}
MAGIC_CHECK_END();
/* free obj */
o->magic = 0;
- free(o);
+ EVAS_MEMPOOL_FREE(_mp_obj, o);
}
static void
NULL
};
+EVAS_MEMPOOL(_mp_obj);
+EVAS_MEMPOOL(_mp_cb);
+
/* public funcs */
/**
* Store a pointer to user data for a smart object.
MAGIC_CHECK_END();
if (!event) return;
if (!func) return;
- cb = calloc(1, sizeof(Evas_Smart_Callback));
+ EVAS_MEMPOOL_INIT(_mp_cb, "evas_smart_callback", Evas_Smart_Callback, 512, );
+ cb = EVAS_MEMPOOL_ALLOC(_mp_cb, Evas_Smart_Callback);
+ if (!cb) return;
+ EVAS_MEMPOOL_PREP(_mp_cb, cb, Evas_Smart_Callback);
cb->event = eina_stringshare_add(event);
cb->func = func;
cb->func_data = (void *)data;
{
o->callbacks = eina_list_remove(o->callbacks, cb);
if (cb->event) eina_stringshare_del(cb->event);
- free(cb);
+ EVAS_MEMPOOL_FREE(_mp_cb, cb);
}
}
}
cb = o->callbacks->data;
o->callbacks = eina_list_remove(o->callbacks, cb);
if (cb->event) eina_stringshare_del(cb->event);
- free(cb);
+ EVAS_MEMPOOL_FREE(_mp_cb, cb);
}
evas_smart_cb_descriptions_resize(&o->callbacks_descriptions, 0);
Evas_Object_Smart *o;
/* alloc obj private data */
- o = calloc(1, sizeof(Evas_Object_Smart));
+ EVAS_MEMPOOL_INIT(_mp_obj, "evas_object_smart", Evas_Object_Smart, 256, NULL);
+ o = EVAS_MEMPOOL_ALLOC(_mp_obj, Evas_Object_Smart);
+ if (!o) return NULL;
+ EVAS_MEMPOOL_PREP(_mp_obj, o, Evas_Object_Smart);
o->magic = MAGIC_OBJ_SMART;
return o;
}
MAGIC_CHECK_END();
/* free obj */
o->magic = 0;
- free(o);
+ EVAS_MEMPOOL_FREE(_mp_obj, o);
}
static void
cso = evas_object_smart_data_get(obj);
if (!cso)
- cso = malloc(sizeof(*cso)); /* users can provide it or realloc() later */
+ cso = calloc(1, sizeof(*cso)); /* users can provide it or realloc() later */
cso->evas = evas_object_evas_get(obj);
clipper = evas_object_rectangle_add(cso->evas);
* @{
*/
+EVAS_MEMPOOL(_mp_obj);
+
/**
* Creates a new text @c Evas_Object on the provided @c Evas canvas.
*
Evas_Object_Text *o;
/* alloc obj private data */
- o = calloc(1, sizeof(Evas_Object_Text));
+ EVAS_MEMPOOL_INIT(_mp_obj, "evas_object_text", Evas_Object_Text, 128, NULL);
+ o = EVAS_MEMPOOL_ALLOC(_mp_obj, Evas_Object_Text);
+ if (!o) return NULL;
+ EVAS_MEMPOOL_PREP(_mp_obj, o, Evas_Object_Text);
o->magic = MAGIC_OBJ_TEXT;
o->prev = o->cur;
#ifdef BIDI_SUPPORT
evas_bidi_props_clean(&o->cur.intl_props);
#endif
o->magic = 0;
- free(o);
+ EVAS_MEMPOOL_FREE(_mp_obj, o);
}
static void
"•\0" "\xe2\x80\xa2\0"
;
+EVAS_MEMPOOL(_mp_obj);
/**
* @internal
Evas_Object_Textblock *o;
/* alloc obj private data */
- o = calloc(1, sizeof(Evas_Object_Textblock));
+ EVAS_MEMPOOL_INIT(_mp_obj, "evas_object_textblock", Evas_Object_Textblock, 64, NULL);
+ o = EVAS_MEMPOOL_ALLOC(_mp_obj, Evas_Object_Textblock);
+ if (!o) return NULL;
+ EVAS_MEMPOOL_PREP(_mp_obj, o, Evas_Object_Textblock);
o->magic = MAGIC_OBJ_TEXTBLOCK;
o->cursor = calloc(1, sizeof(Evas_Textblock_Cursor));
_format_command_init();
}
if (o->repch) eina_stringshare_del(o->repch);
o->magic = 0;
- free(o);
- _format_command_shutdown();
+ EVAS_MEMPOOL_FREE(_mp_obj, o);
+ _format_command_shutdown();
}
Eina_Bool evas_map_inside_get(const Evas_Map *m, Evas_Coord x, Evas_Coord y);
Eina_Bool evas_map_coords_get(const Evas_Map *m, Evas_Coord x, Evas_Coord y, Evas_Coord *mx, Evas_Coord *my, int grab);
-
+/****************************************************************************/
+/*****************************************/
+/********************/
+//#define MPOOL 1
+
+#ifdef MPOOL
+typedef struct _Evas_Mempool Evas_Mempool;
+
+struct _Evas_Mempool
+{
+ int count;
+ int num_allocs;
+ int num_frees;
+ Eina_Mempool *mp;
+};
+# define EVAS_MEMPOOL(x) \
+ static Evas_Mempool x = {0, 0, 0, NULL}
+# define EVAS_MEMPOOL_INIT(x, nam, siz, cnt, ret) \
+ do { \
+ if (!x.mp) { \
+ x.mp = eina_mempool_add("chained_mempool", nam, NULL, sizeof(siz), cnt); \
+ if (!x.mp) { \
+ return ret; \
+ } \
+ } \
+ } while (0)
+# define EVAS_MEMPOOL_ALLOC(x, siz) \
+ eina_mempool_malloc(x.mp, sizeof(siz))
+# define EVAS_MEMPOOL_PREP(x, p, siz) \
+ do { \
+ x.count++; \
+ x.num_allocs++; \
+ memset(p, 0, sizeof(siz)); \
+ } while (0)
+# define EVAS_MEMPOOL_FREE(x, p) \
+ do { \
+ eina_mempool_free(x.mp, p); \
+ x.count--; \
+ x.num_frees++; \
+ if (x.count <= 0) { \
+ eina_mempool_del(x.mp); \
+ x.mp = NULL; \
+ x.count = 0; \
+ } \
+ } while (0)
+#else
+# define EVAS_MEMPOOL(x)
+# define EVAS_MEMPOOL_INIT(x, nam, siz, cnt, ret)
+# define EVAS_MEMPOOL_PREP(x, p, siz)
+# define EVAS_MEMPOOL_ALLOC(x, siz) \
+ calloc(1, sizeof(siz))
+# define EVAS_MEMPOOL_FREE(x, p) \
+ free(p)
+#endif
+/********************/
+/*****************************************/
+/****************************************************************************/
+
#define EVAS_API_OVERRIDE(func, api, prefix) \
(api)->func = prefix##func