Mercurial > MadButterfly
changeset 419:7c921fda21be
Set free function for sh_stext.
_rdman_shape_stext_free() is the free function of sh_stext.
It is assigned to function pointer shape_t::free of sh_stext.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Sun, 26 Jul 2009 22:13:36 +0800 |
parents | af6adacbed07 |
children | 485c563514f4 |
files | src/shape_stext.c |
diffstat | 1 files changed, 24 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/shape_stext.c Sun Jul 26 22:13:20 2009 +0800 +++ b/src/shape_stext.c Sun Jul 26 22:13:36 2009 +0800 @@ -271,9 +271,29 @@ * style_blks */ co_aix x, y; mb_scaled_font_t **scaled_fonts; + int nscaled; + int maxscaled; mb_text_extents_t extents; } sh_stext_t; +static +void _rdman_shape_stext_free(shape_t *shape) { + sh_stext_t *txt_o = (sh_stext_t *)shape; + int i; + + if(txt_o->style_blks) + free((void *)txt_o->style_blks); + if(txt_o->scaled_fonts) { + for(i = 0; i < txt_o->nscaled; i++) + scaled_font_free(txt_o->scaled_fonts[i]); + free(txt_o->scaled_fonts); + } + if(txt_o->txt) + free((void *)txt_o->txt); + + free(txt_o); +} + shape_t *rdman_shape_stext_new(redraw_man_t *rdman, co_aix x, co_aix y, const char *txt) { sh_stext_t *txt_o; @@ -294,11 +314,15 @@ txt_o->x = x; txt_o->y = y; txt_o->scaled_fonts = NULL; + txt_o->nscaled = 0; + txt_o->maxscaled = 0; if(txt_o->txt == NULL) { free(txt_o); txt_o = NULL; } + + txt_o->shape.free = _rdman_shape_stext_free; rdman_shape_man(rdman, (shape_t *)txt_o);