From: Matthias Kramm Date: Tue, 26 May 2009 22:48:40 +0000 (-0700) Subject: fixed a few minor mem leaks X-Git-Tag: version-0-9-1~349 X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=commitdiff_plain;h=71b11cc925e384ecad5b0f48b511bcadc2867f9b fixed a few minor mem leaks --- diff --git a/lib/gfxpoly/convert.c b/lib/gfxpoly/convert.c index 717feba..213cdad 100644 --- a/lib/gfxpoly/convert.c +++ b/lib/gfxpoly/convert.c @@ -354,6 +354,7 @@ void gfxcompactpoly_destroy(gfxcompactpoly_t*poly) int t; for(t=0;tnum_strokes;t++) { free(poly->strokes[t].points); + poly->strokes[t].points = 0; } free(poly->strokes); free(poly); diff --git a/lib/gfxpoly/poly.c b/lib/gfxpoly/poly.c index 9c45bdf..239cba6 100644 --- a/lib/gfxpoly/poly.c +++ b/lib/gfxpoly/poly.c @@ -1277,5 +1277,7 @@ gfxpoly_t* gfxpoly_process(gfxcompactpoly_t*poly, windrule_t*windrule, windconte gfxcompactpoly_t*p = (gfxcompactpoly_t*)status.writer.finish(&status.writer); add_horizontals(p, &windrule_evenodd, context); // output is always even/odd - return gfxpoly_from_gfxcompactpoly(p); + gfxpoly_t*pp = gfxpoly_from_gfxcompactpoly(p); + gfxcompactpoly_destroy(p); + return pp; } diff --git a/lib/gfxpoly/test.c b/lib/gfxpoly/test.c index 4e3c875..82ceb9a 100644 --- a/lib/gfxpoly/test.c +++ b/lib/gfxpoly/test.c @@ -114,12 +114,12 @@ gfxline_t* mkchessboard() return b; } -gfxline_t* make_circles() +gfxline_t* make_circles(int n) { gfxline_t*b = 0; unsigned int c = 0; int t; - for(t=0;t<30;t++) { + for(t=0;ttype = gfx_moveTo; + line[0]->x = x+begin*rx; + line[0]->y = y+begin*ry; for(t=1;t<9;t++) { - line[t-1].next = &line[t]; - line[t].type = gfx_splineTo; + line[t-1]->next = line[t]; + line[t]->type = gfx_splineTo; } - line[t].next = 0; + line[8]->next = 0; #define R(nr,cx,cy,mx,my) \ - line[nr].sx = line[nr-1].x + (cx); \ - line[nr].sy = line[nr-1].y + (cy); \ - line[nr].x = line[nr].sx + (mx); \ - line[nr].y = line[nr].sy + (my); + line[nr]->sx = line[nr-1]->x + (cx); \ + line[nr]->sy = line[nr-1]->y + (cy); \ + line[nr]->x = line[nr]->sx + (mx); \ + line[nr]->y = line[nr]->sy + (my); R(1, -C1*rx, C1*ry, -C2*rx, 0); R(2, -C2*rx, 0, -C1*rx, -C1*ry); R(3, -C1*rx, -C1*ry, 0, -C2*ry); @@ -862,7 +865,9 @@ gfxline_t*gfxline_makecircle(double x,double y,double rx, double ry) R(6, C2*rx, 0, C1*rx, C1*ry); R(7, C1*rx, C1*ry, 0, C2*ry); R(8, 0, C2*ry, -C1*rx, C1*ry); - return line; + gfxline_t*l = line[0]; + free(line); + return l; } gfxbbox_t* gfxline_isrectangle(gfxline_t*_l) diff --git a/lib/q.c b/lib/q.c index 64934a6..1d50ca3 100644 --- a/lib/q.c +++ b/lib/q.c @@ -524,13 +524,14 @@ void trie_rollback(trie_t*t) // ------------------------------- crc32 -------------------------------------- -static unsigned int*crc32 = 0; +static unsigned int crc32[256]; +static char crc32_initialized=0; static void crc32_init(void) { int t; - if(crc32) + if(crc32_initialized) return; - crc32= (unsigned int*)rfx_alloc(sizeof(unsigned int)*256); + crc32_initialized = 1; for(t=0; t<256; t++) { unsigned int c = t; int s;