# HG changeset patch # User Thinker K.F. Li # Date 1218585950 -28800 # Node ID 3f2872a1a2fe3f7902aa169ca615247529a65d2d # Parent 309f1eefbec0c0cfa797cf3492aff03069de27d2 clear objects in *_free() for generated code diff -r 309f1eefbec0 -r 3f2872a1a2fe tools/mb_c_header.m4 --- a/tools/mb_c_header.m4 Wed Aug 13 02:17:19 2008 +0800 +++ b/tools/mb_c_header.m4 Wed Aug 13 08:05:50 2008 +0800 @@ -31,15 +31,18 @@ define([MADBUTTERFLY],[dnl [#ifndef __$1_H_ -#define __$1_H_] +#define __$1_H_ -[typedef struct $1 $1_t;] +typedef struct $1 $1_t; -struct [$1] { - coord_t *root_coord; +struct $1 { + coord_t *root_coord;] $2[]dnl -}; +[}; -[#endif /* __$1_H_ */] +extern $1_t *$1_new(redraw_mant_t *rdman); +extern void $1_free($1_t *obj); + +#endif /* __$1_H_ */] ]) divert[]dnl diff -r 309f1eefbec0 -r 3f2872a1a2fe tools/mb_c_source.m4 --- a/tools/mb_c_source.m4 Wed Aug 13 02:17:19 2008 +0800 +++ b/tools/mb_c_source.m4 Wed Aug 13 08:05:50 2008 +0800 @@ -114,6 +114,49 @@ SIMPORT([STROKE_SHAPE_WITH_PAINT]) divert[]]) +define([F_ADD_LINEAR_PAINT],[[ + stops = paint_linear_stops(obj->$1, 0, NULL); + free(stops); + obj->$1->free(obj->$1); +]]) + +define([F_ADD_RADIAL_PAINT],[[ + stops = paint_radial_stops(obj->$1, 0, NULL); + free(stops); + obj->$1->free(obj->$1); +]]) + +define([F_ADD_PATH],[[ + sh_path_free(obj->$1); +]]); + +define([F_ADD_RECT],[[ + sh_rect_free(obj->$1); +]]); + +define([F_FILL_SHAPE],[[ + obj->$1->free(obj->$1); +]]) + +define([F_STROKE_SHAPE],[[ + obj->$1->free(obj->$1); +]]) + +define([CLEAR_VARS],[divert([-1]) +define([FIMPORT],[IMPORT(]QUOTE($[]1)[,[F_])]) +FIMPORT([ADD_LINEAR_PAINT]) +FIMPORT([ADD_RADIAL_PAINT]) +define([COLOR_STOP]) +define([REF_STOPS]) +FIMPORT([ADD_PATH],) +FIMPORT([ADD_RECT]) +define([ADD_COORD]) +FIMPORT([FILL_SHAPE]) +FIMPORT([STROKE_SHAPE]) +define([FILL_SHAPE_WITH_PAINT]) +define([STROKE_SHAPE_WITH_PAINT]) +divert[]]) + define([MADBUTTERFLY],[dnl [#include #include "mb_types.h" @@ -133,6 +176,13 @@ obj->root_coord = rdman->root_coord; $2 [ return obj; -}] +} + +void $1_free($1_t *obj) { + grad_stop_t *stops; +]CLEAR_VARS[]$2[ + free(obj); +} +]dnl ]) divert[]dnl