comparison src/shape_stext.c @ 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
comparison
equal deleted inserted replaced
418:af6adacbed07 419:7c921fda21be
269 * blocks */ 269 * blocks */
270 int max_nblks; /*!< \brief Available space of 270 int max_nblks; /*!< \brief Available space of
271 * style_blks */ 271 * style_blks */
272 co_aix x, y; 272 co_aix x, y;
273 mb_scaled_font_t **scaled_fonts; 273 mb_scaled_font_t **scaled_fonts;
274 int nscaled;
275 int maxscaled;
274 mb_text_extents_t extents; 276 mb_text_extents_t extents;
275 } sh_stext_t; 277 } sh_stext_t;
278
279 static
280 void _rdman_shape_stext_free(shape_t *shape) {
281 sh_stext_t *txt_o = (sh_stext_t *)shape;
282 int i;
283
284 if(txt_o->style_blks)
285 free((void *)txt_o->style_blks);
286 if(txt_o->scaled_fonts) {
287 for(i = 0; i < txt_o->nscaled; i++)
288 scaled_font_free(txt_o->scaled_fonts[i]);
289 free(txt_o->scaled_fonts);
290 }
291 if(txt_o->txt)
292 free((void *)txt_o->txt);
293
294 free(txt_o);
295 }
276 296
277 shape_t *rdman_shape_stext_new(redraw_man_t *rdman, co_aix x, co_aix y, 297 shape_t *rdman_shape_stext_new(redraw_man_t *rdman, co_aix x, co_aix y,
278 const char *txt) { 298 const char *txt) {
279 sh_stext_t *txt_o; 299 sh_stext_t *txt_o;
280 300
292 txt_o->nblks = 0; 312 txt_o->nblks = 0;
293 txt_o->max_nblks = 0; 313 txt_o->max_nblks = 0;
294 txt_o->x = x; 314 txt_o->x = x;
295 txt_o->y = y; 315 txt_o->y = y;
296 txt_o->scaled_fonts = NULL; 316 txt_o->scaled_fonts = NULL;
317 txt_o->nscaled = 0;
318 txt_o->maxscaled = 0;
297 319
298 if(txt_o->txt == NULL) { 320 if(txt_o->txt == NULL) {
299 free(txt_o); 321 free(txt_o);
300 txt_o = NULL; 322 txt_o = NULL;
301 } 323 }
324
325 txt_o->shape.free = _rdman_shape_stext_free;
302 326
303 rdman_shape_man(rdman, (shape_t *)txt_o); 327 rdman_shape_man(rdman, (shape_t *)txt_o);
304 328
305 return (shape_t *)txt_o; 329 return (shape_t *)txt_o;
306 } 330 }