Remove memory leaks in the SVG code
This commit is contained in:
parent
74a615d5af
commit
9f6d550837
|
|
@ -265,8 +265,11 @@ void com_hardcopy(wordlist *wl)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tempf && *device)
|
if (tempf && *device) {
|
||||||
(void) unlink(fname);
|
(void) unlink(fname);
|
||||||
|
}
|
||||||
|
|
||||||
|
tfree(fname);
|
||||||
|
|
||||||
/* restore previous graphics context by retrieving the previous currentgraph */
|
/* restore previous graphics context by retrieving the previous currentgraph */
|
||||||
PopGraphContext();
|
PopGraphContext();
|
||||||
|
|
|
||||||
|
|
@ -181,16 +181,20 @@ SVG_Init(void)
|
||||||
Cfg.ints[SVG_GRID_WIDTH] = 0;
|
Cfg.ints[SVG_GRID_WIDTH] = 0;
|
||||||
|
|
||||||
if (cp_getvar("hcopyfont", CP_STRING, &strbuf, sizeof(strbuf))) {
|
if (cp_getvar("hcopyfont", CP_STRING, &strbuf, sizeof(strbuf))) {
|
||||||
|
tfree(Cfg.strings[SVG_FONT]);
|
||||||
Cfg.strings[SVG_FONT] = strdup(strbuf);
|
Cfg.strings[SVG_FONT] = strdup(strbuf);
|
||||||
}
|
}
|
||||||
else if (!stropts_isset) {
|
else if (!stropts_isset) {
|
||||||
|
tfree(Cfg.strings[SVG_FONT]);
|
||||||
Cfg.strings[SVG_FONT] = strdup("Helvetica");
|
Cfg.strings[SVG_FONT] = strdup("Helvetica");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cp_getvar("hcopyfontfamily", CP_STRING, &strbuf, sizeof(strbuf))) {
|
if (cp_getvar("hcopyfontfamily", CP_STRING, &strbuf, sizeof(strbuf))) {
|
||||||
|
tfree(Cfg.strings[SVG_FONT_FAMILY]);
|
||||||
Cfg.strings[SVG_FONT_FAMILY] = strdup(strbuf);
|
Cfg.strings[SVG_FONT_FAMILY] = strdup(strbuf);
|
||||||
}
|
}
|
||||||
else if (!stropts_isset){
|
else if (!stropts_isset){
|
||||||
|
tfree(Cfg.strings[SVG_FONT_FAMILY]);
|
||||||
Cfg.strings[SVG_FONT_FAMILY] = strdup("Helvetica");
|
Cfg.strings[SVG_FONT_FAMILY] = strdup("Helvetica");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -203,8 +207,10 @@ SVG_Init(void)
|
||||||
sprintf(colorN, "color%d", colorid);
|
sprintf(colorN, "color%d", colorid);
|
||||||
if (cp_getvar(colorN, CP_STRING, colorstring, sizeof(colorstring))) {
|
if (cp_getvar(colorN, CP_STRING, colorstring, sizeof(colorstring))) {
|
||||||
colors[colorid] = strdup(colorstring);
|
colors[colorid] = strdup(colorstring);
|
||||||
if (colorid == 0)
|
if (colorid == 0) {
|
||||||
|
tfree(Cfg.strings[SVG_BACKGROUND]);
|
||||||
Cfg.strings[SVG_BACKGROUND] = strdup(colors[0]);
|
Cfg.strings[SVG_BACKGROUND] = strdup(colors[0]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
colors[colorid] = strdup(svgcolors[colorid]);
|
colors[colorid] = strdup(svgcolors[colorid]);
|
||||||
|
|
@ -302,6 +308,8 @@ SVG_NewViewport(GRAPH *graph)
|
||||||
|
|
||||||
/* Allocate and initialise per-graph data. */
|
/* Allocate and initialise per-graph data. */
|
||||||
|
|
||||||
|
tfree(graph->devdep);
|
||||||
|
|
||||||
graph->devdep = TMALLOC(SVGdevdep, 1);
|
graph->devdep = TMALLOC(SVGdevdep, 1);
|
||||||
ddp = DEVDEP_P(graph);
|
ddp = DEVDEP_P(graph);
|
||||||
ddp->lastx = ddp->lasty = -1;
|
ddp->lastx = ddp->lasty = -1;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue