ref: 89b72c4f5b5166aef068a0708b5f1cff993b9fb7
parent: 30fddca2d52ece7c21aff95615e0f8410eed772a
author: Ali Gholami Rudi <ali@rudi.ir>
date: Fri Dec 5 18:14:36 EST 2014
roff: free() everything at exit
--- a/hyph.c
+++ b/hyph.c
@@ -278,6 +278,16 @@
hcodedict = dict_make(-1, 0, 1);
}
+void hyph_done(void)
+{
+ if (hwdict)
+ dict_free(hwdict);
+ if (hydict)
+ dict_free(hydict);
+ if (hcodedict)
+ dict_free(hcodedict);
+}
+
void tr_hpf(char **args)
{
/* reseting the patterns */
--- a/map.c
+++ b/map.c
@@ -35,3 +35,9 @@
map_buf[2] = '\0';
return map_buf;
}
+
+void map_done(void)
+{
+ if (mapdict)
+ dict_free(mapdict);
+}
--- a/reg.c
+++ b/reg.c
@@ -275,6 +275,8 @@
for (i = 0; i < LEN(envs); i++)
if (envs[i])
env_free(envs[i]);
+ for (i = 0; i < LEN(sregs); i++)
+ free(sregs[i]);
}
static int oenv[NPREV]; /* environment stack */
--- a/roff.c
+++ b/roff.c
@@ -114,7 +114,10 @@
out("f%d\n", n_f);
ret = render();
out("V%d\n", n_p);
+ hyph_done();
+ tr_done();
env_done();
dev_close();
+ map_done();
return ret;
}
--- a/roff.h
+++ b/roff.h
@@ -287,6 +287,7 @@
void hyphenate(char *hyphs, char *word, int flg);
void hyph_init(void);
+void hyph_done(void);
/* adjustment types */
#define AD_C 0 /* center */
@@ -371,6 +372,7 @@
void tr_transparent(char **args);
void tr_init(void);
+void tr_done(void);
int tr_readargs(char **args, struct sbuf *sbuf,
int (*next)(void), void (*back)(int));
@@ -411,6 +413,7 @@
int map(char *s); /* map name s to an index */
char *map_name(int id); /* return the name mapped to id */
+void map_done(void);
/* colors */
#define CLR_R(c) (((c) >> 16) & 0xff)
--- a/tr.c
+++ b/tr.c
@@ -1079,3 +1079,8 @@
str_dset(map(cmds[i].id), &cmds[i]);
cmap = dict_make(-1, 0, 0);
}
+
+void tr_done(void)
+{
+ dict_free(cmap);
+}