improve DEBUG_LEAKS handling and fix freeing some locs
This commit is contained in:
parent
af39f3b7b0
commit
2b06709bf3
5
edit.c
5
edit.c
@ -28,7 +28,7 @@
|
||||
|
||||
#ifndef MKSH_NO_CMDLINE_EDITING
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.264 2013/02/10 17:41:03 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.265 2013/02/10 19:05:36 tg Exp $");
|
||||
|
||||
/*
|
||||
* in later versions we might use libtermcap for this, but since external
|
||||
@ -5451,7 +5451,8 @@ x_init(void)
|
||||
void
|
||||
x_done(void)
|
||||
{
|
||||
afreeall(AEDIT);
|
||||
if (x_tab != NULL)
|
||||
afreeall(AEDIT);
|
||||
}
|
||||
#endif
|
||||
#endif /* !MKSH_NO_CMDLINE_EDITING */
|
||||
|
23
main.c
23
main.c
@ -34,7 +34,7 @@
|
||||
#include <locale.h>
|
||||
#endif
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.257 2013/02/10 18:17:30 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.258 2013/02/10 19:05:37 tg Exp $");
|
||||
|
||||
extern char **environ;
|
||||
|
||||
@ -955,7 +955,7 @@ quitenv(struct shf *shf)
|
||||
int fd;
|
||||
|
||||
yyrecursive_pop(true);
|
||||
if (ep->oenv && ep->oenv->loc != ep->loc)
|
||||
while (ep->oenv && ep->oenv->loc != ep->loc)
|
||||
popblock();
|
||||
if (ep->savefd != NULL) {
|
||||
for (fd = 0; fd < NUFILE; fd++)
|
||||
@ -971,8 +971,6 @@ quitenv(struct shf *shf)
|
||||
* Either main shell is exiting or cleanup_parents_env() was called.
|
||||
*/
|
||||
if (ep->oenv == NULL) {
|
||||
struct block *l;
|
||||
|
||||
if (ep->type == E_NONE) {
|
||||
/* Main shell exiting? */
|
||||
#if HAVE_PERSISTENT_HISTORY
|
||||
@ -999,18 +997,10 @@ quitenv(struct shf *shf)
|
||||
}
|
||||
if (shf)
|
||||
shf_close(shf);
|
||||
#ifdef DEBUG_LEAKS
|
||||
l = e->loc;
|
||||
while (l) {
|
||||
afreeall(&l->area);
|
||||
l = l->next;
|
||||
}
|
||||
#endif
|
||||
reclaim();
|
||||
#ifdef DEBUG_LEAKS
|
||||
#ifndef MKSH_NO_CMDLINE_EDITING
|
||||
if (Flag(FTALKING))
|
||||
x_done();
|
||||
x_done();
|
||||
#endif
|
||||
afreeall(APERM);
|
||||
if (tty_fd >= 0)
|
||||
@ -1074,6 +1064,13 @@ cleanup_proc_env(void)
|
||||
static void
|
||||
reclaim(void)
|
||||
{
|
||||
struct block *l;
|
||||
|
||||
while ((l = e->loc) && (!e->oenv || e->oenv->loc != l)) {
|
||||
e->loc = l->next;
|
||||
afreeall(&l->area);
|
||||
}
|
||||
|
||||
remove_temps(e->temps);
|
||||
e->temps = NULL;
|
||||
afreeall(&e->area);
|
||||
|
Loading…
Reference in New Issue
Block a user