Mercurial > MadButterfly
changeset 866:9a7ac4487849
Allocate sh_rect_t objects from an elmpool
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Thu, 23 Sep 2010 10:14:05 +0800 |
parents | 48df0f97f09e |
children | 4f8d53be9488 |
files | include/mb_redraw_man.h src/redraw_man.c src/shape_rect.c |
diffstat | 3 files changed, 15 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/include/mb_redraw_man.h Thu Sep 23 09:55:37 2010 +0800 +++ b/include/mb_redraw_man.h Thu Sep 23 10:14:05 2010 +0800 @@ -51,6 +51,7 @@ elmpool_t *coord_pool; elmpool_t *shnode_pool; elmpool_t *sh_path_pool; + elmpool_t *sh_rect_pool; elmpool_t *observer_pool; elmpool_t *subject_pool; elmpool_t *paint_color_pool;
--- a/src/redraw_man.c Thu Sep 23 09:55:37 2010 +0800 +++ b/src/redraw_man.c Thu Sep 23 10:14:05 2010 +0800 @@ -640,6 +640,7 @@ int redraw_man_init(redraw_man_t *rdman, mbe_t *cr, mbe_t *backend) { extern void redraw_man_destroy(redraw_man_t *rdman); extern int _sh_path_size; + extern int _sh_rect_size; extern int _paint_color_size; observer_t *addrm_ob; extern void addrm_monitor_hdlr(event_t *evt, void *arg); @@ -655,6 +656,7 @@ rdman->coord_pool = elmpool_new(sizeof(coord_t), 16); rdman->shnode_pool = elmpool_new(sizeof(shnode_t), 16); rdman->sh_path_pool = elmpool_new(_sh_path_size, 16); + rdman->sh_rect_pool = elmpool_new(_sh_rect_size, 16); rdman->observer_pool = elmpool_new(sizeof(observer_t), 32); rdman->subject_pool = elmpool_new(sizeof(subject_t), 32); rdman->paint_color_pool = elmpool_new(_paint_color_size, 64); @@ -724,6 +726,8 @@ elmpool_free(rdman->shnode_pool); if(rdman->sh_path_pool) elmpool_free(rdman->sh_path_pool); + if(rdman->sh_rect_pool) + elmpool_free(rdman->sh_rect_pool); if(rdman->observer_pool) elmpool_free(rdman->observer_pool); if(rdman->subject_pool) @@ -784,6 +788,7 @@ elmpool_free(rdman->geo_pool); elmpool_free(rdman->shnode_pool); elmpool_free(rdman->sh_path_pool); + elmpool_free(rdman->sh_rect_pool); elmpool_free(rdman->observer_pool); elmpool_free(rdman->subject_pool); elmpool_free(rdman->paint_color_pool);
--- a/src/shape_rect.c Thu Sep 23 09:55:37 2010 +0800 +++ b/src/shape_rect.c Thu Sep 23 10:14:05 2010 +0800 @@ -12,10 +12,16 @@ co_aix w, h; co_aix rx, ry; co_aix poses[12][2]; + + redraw_man_t *rdman; /*!< \brief This is used by sh_rect_free() */ } sh_rect_t; +int _sh_rect_size = sizeof(sh_rect_t); + static void sh_rect_free(shape_t *shape) { - free(shape); + sh_rect_t *rect = (sh_rect_t *)shape; + + elmpool_elm_free(rect->rdman->sh_rect_pool, rect); } shape_t *rdman_shape_rect_new(redraw_man_t *rdman, @@ -23,7 +29,7 @@ co_aix rx, co_aix ry) { sh_rect_t *rect; - rect = (sh_rect_t *)malloc(sizeof(sh_rect_t)); + rect = (sh_rect_t *)elmpool_elm_alloc(rdman->sh_rect_pool); if(rect == NULL) return NULL; @@ -37,6 +43,7 @@ rect->rx = rx; rect->ry = ry; rect->shape.free = sh_rect_free; + rect->rdman = rdman; rdman_shape_man(rdman, (shape_t *)rect);