summaryrefslogtreecommitdiff
path: root/kicad
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-08-30 15:14:23 -0300
committerWerner Almesberger <werner@almesberger.net>2016-08-30 15:16:55 -0300
commitfefaf1bd733e241242e1f75ba04d932f17951354 (patch)
treea88cf0fb5de37b3ea0e3732a11d63a891dcbc1db /kicad
parent35f2c9c26e6d7975e4c29eaa79dd10e29f24dea4 (diff)
downloadeeshow-fefaf1bd733e241242e1f75ba04d932f17951354.tar.gz
eeshow-fefaf1bd733e241242e1f75ba04d932f17951354.tar.bz2
eeshow-fefaf1bd733e241242e1f75ba04d932f17951354.zip
fix a few memory leaks (in non-interactive mode)
We now leak less than 1 MB on valgrind --leak-check=full eeshow -N 1 neo900.pro -- png -o foo.png instead of about 3.5 MB. The plan is as follows: - fix memory leaks in simple operations in on-interactive mode, - suppress what cannot be fixed (e.g., when comes from libraries), - move on to more complex operations, - then start fixing interactive mode.
Diffstat (limited to 'kicad')
-rw-r--r--kicad/lib-parse.c4
-rw-r--r--kicad/pl-render.c6
-rw-r--r--kicad/sch-render.c4
3 files changed, 12 insertions, 2 deletions
diff --git a/kicad/lib-parse.c b/kicad/lib-parse.c
index e24e37a..e2f8a29 100644
--- a/kicad/lib-parse.c
+++ b/kicad/lib-parse.c
@@ -360,6 +360,10 @@ static void free_objs(struct lib_obj *objs)
while (objs) {
next = objs->next;
switch (objs->type) {
+ case lib_obj_poly:
+ free(objs->u.poly.x);
+ free(objs->u.poly.y);
+ break;
case lib_obj_text:
free((char *) objs->u.text.s);
break;
diff --git a/kicad/pl-render.c b/kicad/pl-render.c
index c56519c..ded0373 100644
--- a/kicad/pl-render.c
+++ b/kicad/pl-render.c
@@ -61,9 +61,11 @@ static char *expand(const struct pl_ctx *pl, const char *s,
unsigned size = 0;
unsigned len;
char *x;
+ bool do_free;
unsigned n;
while (1) {
+ do_free = 0;
p = strchr(s, '%');
if (!p)
break;
@@ -88,6 +90,7 @@ static char *expand(const struct pl_ctx *pl, const char *s,
for (sch = sheets; sch; sch = sch->next)
n++;
alloc_printf(&x, "%u", n);
+ do_free = 1;
break;
case 'P':
x = "%P"; // sheet path
@@ -101,6 +104,7 @@ static char *expand(const struct pl_ctx *pl, const char *s,
sch = sch->next)
n++;
alloc_printf(&x, "%u", n);
+ do_free = 1;
break;
case 'T':
x = (char *) sheet->title;
@@ -122,6 +126,8 @@ static char *expand(const struct pl_ctx *pl, const char *s,
s = p + 2;
memcpy(res + size, x, len);
size += len;
+ if (do_free)
+ free(x);
}
len = strlen(s);
diff --git a/kicad/sch-render.c b/kicad/sch-render.c
index 52be40f..27b5ecb 100644
--- a/kicad/sch-render.c
+++ b/kicad/sch-render.c
@@ -111,8 +111,8 @@ static void do_hsheet_text(const struct sch_obj *obj,
text_show(&sheet_txt, gfx, COLOR_HSHEET_SHEET, LAYER_HSHEET_FIELD);
text_show(&file_txt, gfx, COLOR_HSHEET_FILE, LAYER_HSHEET_FIELD);
-// free((void *) ctx->sheet);
-// free((void *) ctx->file);
+ free((void *) sheet_txt.s);
+ free((void *) file_txt.s);
}