From a56b4764d2773a957658e496b0e2863e27b0bca9 Mon Sep 17 00:00:00 2001 From: lecoanet Date: Tue, 18 Jan 2005 14:53:32 +0000 Subject: Fixed a big memory leak in Geo.c related to polys and tristrips. Fixed a typo in the find closest command related to atomic groups. --- generic/Curve.c | 11 +++++++---- generic/Geo.c | 6 ++---- generic/tkZinc.c | 18 ++++++++++-------- generic/tkZinc.h | 1 + 4 files changed, 20 insertions(+), 16 deletions(-) (limited to 'generic') diff --git a/generic/Curve.c b/generic/Curve.c index b580d56..1ce76e5 100644 --- a/generic/Curve.c +++ b/generic/Curve.c @@ -507,7 +507,7 @@ UpdateTristrip(CurveItem cv, unsigned int j, k; int i; - /*printf("UpdateTristrips sur %d\n", ((ZnItem) cv)->id);*/ + //printf("UpdateTristrips sur %d\n", ((ZnItem) cv)->id); gluTessProperty(ZnTesselator.tess, GLU_TESS_WINDING_RULE, (GLdouble) cv->fill_rule); if (cv->tristrip.num_strips == 0) { @@ -552,14 +552,16 @@ UpdateTristrip(CurveItem cv, } gluTessEndPolygon(ZnTesselator.tess); cdata = ZnTesselator.combine_list; + //printf("Combine length: %d\n", ZnTesselator.combine_length); while (cdata) { + ZnTesselator.combine_length--; cnext = cdata->next; ZnFree(cdata); cdata = cnext; } ZnTesselator.combine_list = NULL; } - /*printf("Fin UpdateTristrips sur %d\n", ((ZnItem) cv)->id);*/ + //printf("Fin UpdateTristrips sur %d\n", ((ZnItem) cv)->id); } static void @@ -572,7 +574,7 @@ UpdateOutlines(CurveItem cv, unsigned int j, k; int i; - /*printf("UpdateOutlines sur %d\n", ((ZnItem) cv)->id);*/ + //printf("UpdateOutlines sur %d\n", ((ZnItem) cv)->id); gluTessProperty(ZnTesselator.tess, GLU_TESS_WINDING_RULE, (GLdouble) cv->fill_rule); if (cv->outlines.num_contours == 0) { @@ -611,13 +613,14 @@ UpdateOutlines(CurveItem cv, gluTessEndPolygon(ZnTesselator.tess); cdata = ZnTesselator.combine_list; while (cdata) { + ZnTesselator.combine_length--; cnext = cdata->next; ZnFree(cdata); cdata = cnext; } ZnTesselator.combine_list = NULL; } - /*printf("Fin UpdateOutlines sur %d\n", ((ZnItem) cv)->id);*/ + //printf("Fin UpdateOutlines sur %d\n", ((ZnItem) cv)->id); } diff --git a/generic/Geo.c b/generic/Geo.c index ed33e4b..8ee530a 100644 --- a/generic/Geo.c +++ b/generic/Geo.c @@ -91,8 +91,7 @@ ZnPolyFree(ZnPoly *poly) ZnFree(poly->contours[i].controls); }*/ } - if ((poly->contours != &poly->contour1) && - (poly->num_contours > 1)) { + if (poly->contours != &poly->contour1) { ZnFree(poly->contours); } poly->num_contours = 0; @@ -121,8 +120,7 @@ ZnTriFree(ZnTriStrip *tristrip) for (i = 0; i < tristrip->num_strips; i++) { ZnFree(tristrip->strips[i].points); } - if ((tristrip->strips != &tristrip->strip1) && - (tristrip->num_strips > 1)) { + if (tristrip->strips != &tristrip->strip1) { ZnFree(tristrip->strips); } tristrip->num_strips = 0; diff --git a/generic/tkZinc.c b/generic/tkZinc.c index e9fa9de..6f0ec05 100644 --- a/generic/tkZinc.c +++ b/generic/tkZinc.c @@ -3194,7 +3194,7 @@ FindItems(ZnWInfo *wi, if (argc > (first+4)) { result = ZnItemWithTagOrId(wi, args[first+4], &item, search_var); if ((result == TCL_OK) && (item != ZN_NO_ITEM)) { - if ((item->class == ZnGroup) && !ZnGroupAtomic) { + if ((item->class == ZnGroup) && !ZnGroupAtomic(item)) { ps.in_group = item; } else { @@ -8742,11 +8742,11 @@ ZnTessBegin(GLenum type, tristrips->num_strips * sizeof(ZnStrip)); tristrips->strips[tristrips->num_strips-1].fan = (type==GL_TRIANGLE_FAN); } - /*printf("Début de fragment de type: %s\n", - (type == GL_TRIANGLE_FAN) ? "FAN" : - (type == GL_TRIANGLE_STRIP) ? "STRIP" : - (type == GL_TRIANGLES) ? "TRIANGLES" : - (type == GL_LINE_LOOP) ? "LINE LOOP" : "");*/ + //printf("Début de fragment de type: %s\n", + //(type == GL_TRIANGLE_FAN) ? "FAN" : + //(type == GL_TRIANGLE_STRIP) ? "STRIP" : + //(type == GL_TRIANGLES) ? "TRIANGLES" : + //(type == GL_LINE_LOOP) ? "LINE LOOP" : ""); } static void @@ -8821,8 +8821,9 @@ ZnTessCombine(GLdouble coords[3], cdata->next = ZnTesselator.combine_list; ZnTesselator.combine_list = cdata; *out_data = &cdata->v; - /*printf("Création d'un nouveau sommet en %g %g\n", - cdata->v[0], cdata->v[1]);*/ + ZnTesselator.combine_length++; + //printf("Création d'un nouveau sommet en %g %g\n", + //cdata->v[0], cdata->v[1]); } static void @@ -8901,6 +8902,7 @@ InitZinc(Tcl_Interp *interp) { */ ZnTesselator.tess = gluNewTess(); ZnTesselator.combine_list = NULL; + ZnTesselator.combine_length = 0; gluTessCallback(ZnTesselator.tess, GLU_TESS_BEGIN_DATA, (_GLUfuncptr) ZnTessBegin); gluTessCallback(ZnTesselator.tess, GLU_TESS_VERTEX_DATA, diff --git a/generic/tkZinc.h b/generic/tkZinc.h index c24dc08..13b067c 100644 --- a/generic/tkZinc.h +++ b/generic/tkZinc.h @@ -73,6 +73,7 @@ typedef struct _ZnTess { GLUtesselator *tess; ZnCombineData *combine_list; int type; + int combine_length; } ZnTess; extern ZnList ZnWorkPoints; -- cgit v1.1