Mercurial > MadButterfly
diff tools/mb_c_source.m4 @ 67:3f2872a1a2fe
clear objects in *_free() for generated code
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Wed, 13 Aug 2008 08:05:50 +0800 |
parents | 309f1eefbec0 |
children | 018546012798 |
line wrap: on
line diff
--- 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 <stdio.h> #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