# HG changeset patch # User Thinker K.F. Li # Date 1248617616 -28800 # Node ID 7c921fda21be238dc2976b97b102d3c59ab9fb76 # Parent af6adacbed07ff13dff82f134b05b28fe7cae103 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. diff -r af6adacbed07 -r 7c921fda21be src/shape_stext.c --- 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);