From e4d5d4702d8859b69119f8dfb6e06827d9992da0 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 4 Oct 2006 01:18:06 +0000 Subject: image widget memory leaks fixed (thanks to Magne Torresen) git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@721 3ae390bd-cb1e-0410-b409-cd5a39f66f1f --- widget_image.c | 47 +++++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/widget_image.c b/widget_image.c index 17d73de..cba52d7 100644 --- a/widget_image.c +++ b/widget_image.c @@ -1,4 +1,4 @@ -/* $Id: widget_image.c,v 1.10 2006/09/07 09:06:25 reinelt Exp $ +/* $Id: widget_image.c,v 1.11 2006/09/28 04:08:33 reinelt Exp $ * * image widget handling * @@ -21,6 +21,9 @@ * * * $Log: widget_image.c,v $ + * Revision 1.11 2006/09/28 04:08:33 reinelt + * image widget memory leaks fixed (thanks to Magne Tørresen) + * * Revision 1.10 2006/09/07 09:06:25 reinelt * lots of wrong printf formats corrected (thanks to Ernst Bachmann) * @@ -110,25 +113,25 @@ static void widget_image_render(const char *Name, WIDGET_IMAGE * Image) if (Image->bitmap) { int i; for (i = 0; i < Image->height * Image->width; i++) { - RGBA empty = { R: 0x00, G: 0x00, B: 0x00, A:0x00 }; + RGBA empty = { R: 0x00, G: 0x00, B: 0x00, A:0x00 }; Image->bitmap[i] = empty; } } - + if (Image->file == NULL || Image->file[0] == '\0') { error("Warning: Image %s has no file", Name); return; } - + fd = fopen(Image->file, "rb"); if (fd == NULL) { error("Warning: Image %s: fopen(%s) failed: %s", Name, Image->file, strerror(errno)); return; } - + gdImage = gdImageCreateFromPng(fd); fclose(fd); - + if (fd == NULL) { error("Warning: Image %s: CreateFromPng(%s) failed!", Name, Image->file); return; @@ -137,14 +140,12 @@ static void widget_image_render(const char *Name, WIDGET_IMAGE * Image) /* maybe resize bitmap */ if (gdImage->sx > Image->width) { Image->width = gdImage->sx; - if (Image->bitmap) - free(Image->bitmap); + free(Image->bitmap); Image->bitmap = NULL; } if (gdImage->sy > Image->height) { Image->height = gdImage->sy; - if (Image->bitmap) - free(Image->bitmap); + free(Image->bitmap); Image->bitmap = NULL; } if (Image->bitmap == NULL && Image->width > 0 && Image->height > 0) { @@ -155,11 +156,11 @@ static void widget_image_render(const char *Name, WIDGET_IMAGE * Image) return; } for (i = 0; i < Image->height * Image->width; i++) { - RGBA empty = { R: 0x00, G: 0x00, B: 0x00, A:0x00 }; + RGBA empty = { R: 0x00, G: 0x00, B: 0x00, A:0x00 }; Image->bitmap[i] = empty; } } - + /* finally really render it */ if (Image->visible) { for (x = 0; x < gdImage->sx; x++) { @@ -181,6 +182,10 @@ static void widget_image_render(const char *Name, WIDGET_IMAGE * Image) } } } + + /* free image */ + gdImageDestroy(gdImage); + } @@ -194,10 +199,9 @@ static void widget_image_update(void *Self) if (W->parent == NULL) { /* evaluate expressions */ - if (Image->file) { - free(Image->file); - Image->file = NULL; - } + free(Image->file); + Image->file = NULL; + if (Image->file_tree != NULL) { Eval(Image->file_tree, &result); Image->file = strdup(R2S(&result)); @@ -239,8 +243,9 @@ static void widget_image_update(void *Self) W->class->draw(W); /* add a new one-shot timer */ - timer_add(widget_image_update, Self, Image->update, 1); - + if (Image->update > 0) { + timer_add(widget_image_update, Self, Image->update, 1); + } } @@ -313,10 +318,8 @@ int widget_image_quit(WIDGET * Self) if (Self->parent == NULL) { if (Self->data) { WIDGET_IMAGE *Image = Self->data; - if (Image->bitmap) - free(Image->bitmap); - if (Image->file) - free(Image->file); + free(Image->bitmap); + free(Image->file); DelTree(Image->file_tree); DelTree(Image->update_tree); DelTree(Image->visible_tree); -- cgit v1.2.3 s='logheader'>2014-09-04The ca-AB-Calgary file has an invalid line. Fix it.Mauro Carvalho Chehab1-2/+1 Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com> 2014-09-04Remove zeros on the left for channel frequenciesMauro Carvalho Chehab34-794/+794 Those zeros are there just to align the entries. However, we'll convert them to DVBv5, and the conversion tools won't keep the same alignment. This is not needed for the conversion itself, but we want to do the conversion on both directions and see if the file will remain the same. Stripping those useless zeros makes easier for us to double check if something got badly converted. Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com> 2014-09-02Add Brazil's remaining states tablesMauro Carvalho Chehab117-0/+12386 Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com> 2014-09-02Add Brazil's Goias state tablesMauro Carvalho Chehab22-0/+2560 Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com> 2014-09-02Add Brazil's Rio de Janeiro state tablesMauro Carvalho Chehab29-0/+3828 Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com> 2014-09-02Add Brazil's Paraiba state tablesMauro Carvalho Chehab45-0/+2600 Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com> 2014-09-02Add Brazil's Sergipe state tablesMauro Carvalho Chehab47-0/+3563 Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com> 2014-09-02Add Brazil's Santa Catarina state tablesMauro Carvalho Chehab56-0/+4257 Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com> 2014-09-02Add Brazil's Parana state tablesMauro Carvalho Chehab60-0/+5284 Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com> 2014-09-02Add Brazil's Minas Gerais state tablesMauro Carvalho Chehab62-0/+3695 Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com> 2014-09-02Add Brazil's Rio Grande do Sul state tablesMauro Carvalho Chehab69-0/+4731 Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com> 2014-09-02Add Brazil's Bahia state tablesMauro Carvalho Chehab83-0/+6397 Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com> 2014-09-02Add Brazil's Sao Paulo state tablesMauro Carvalho Chehab197-0/+23613 Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>