Mercurial > MadButterfly
diff src/event.c @ 158:c1cdd3fcd28f
Postponing rdman_coord_free() and rdman_remove_shape().
rdman will access free memory if coords or shapes are free when it
is dirty. The requests are postponed until rdman is clean.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Fri, 03 Oct 2008 10:22:08 +0800 |
parents | 1695a4b02b14 |
children | b90abd31a281 |
line wrap: on
line diff
--- a/src/event.c Wed Oct 01 16:30:05 2008 +0800 +++ b/src/event.c Fri Oct 03 10:22:08 2008 +0800 @@ -23,6 +23,8 @@ return OK; } +DARRAY_DEFINE(geos, geo_t *); + /*! \brief Add a geo_t object to general geo list. * * General geo list can use to temporary keep a list of geo_t @@ -31,21 +33,10 @@ * from a redraw manager. */ static int add_gen_geo(redraw_man_t *rdman, geo_t *geo) { - int max_gen_geos; int r; - if(rdman->n_gen_geos >= rdman->max_gen_geos) { - max_gen_geos = rdman->max_gen_geos + ARRAY_EXT_SZ; - r = extend_memblk((void **)&rdman->gen_geos, - sizeof(geo_t *) * rdman->n_gen_geos, - sizeof(geo_t *) * max_gen_geos); - if(r != OK) - return ERR; - rdman->max_gen_geos = max_gen_geos; - } - - rdman->gen_geos[rdman->n_gen_geos++] = geo; - return OK; + r = geos_add(&rdman->gen_geos, geo); + return r == 0? OK: ERR; } static int collect_shapes_at_point(redraw_man_t *rdman, @@ -57,7 +48,7 @@ if(r != OK) return ERR; - rdman->n_gen_geos = 0; + rdman->gen_geos.num = 0; for(geo = rdman_geos(rdman, NULL); geo != NULL; @@ -94,9 +85,9 @@ cairo_t *cr; int i; - geos = rdman->gen_geos; + geos = rdman->gen_geos.ds; cr = rdman->cr; - for(i = rdman->n_gen_geos - 1; i >= 0; i--) { + for(i = rdman->gen_geos.num - 1; i >= 0; i--) { geo = geos[i]; if(geo->flags & GEF_HIDDEN) continue;