Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/xlint/lint1 lint: free the designator as soon as it ...



details:   https://anonhg.NetBSD.org/src/rev/ba6ebb66422d
branches:  trunk
changeset: 1019941:ba6ebb66422d
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Mar 25 21:45:10 2021 +0000

description:
lint: free the designator as soon as it is no longer needed

One of the latest "refactorings" introduced a small and practically
unimportant memory leak.  If the last initializer in an initialization
had a designator, that designator was not freed.

When the "current initialization" was still a global variable with
unlimited lifetime, it was freed at the beginning of the next
initialization.  After the refactorings, this "next initialization"
could no longer see anything from the previous initialization since all
references have been cleaned up at that point.  Freeing the memory so
late and in an almost totally unrelated place was a bad idea anyway.

diffstat:

 usr.bin/xlint/lint1/init.c |  12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diffs (41 lines):

diff -r 0a9c693f1cf6 -r ba6ebb66422d usr.bin/xlint/lint1/init.c
--- a/usr.bin/xlint/lint1/init.c        Thu Mar 25 21:37:10 2021 +0000
+++ b/usr.bin/xlint/lint1/init.c        Thu Mar 25 21:45:10 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: init.c,v 1.129 2021/03/25 21:36:41 rillig Exp $        */
+/*     $NetBSD: init.c,v 1.130 2021/03/25 21:45:10 rillig Exp $        */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: init.c,v 1.129 2021/03/25 21:36:41 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.130 2021/03/25 21:45:10 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -557,10 +557,6 @@
        if (initerr)
                return;
 
-       /* TODO: merge into init_using_expr */
-       while (current_designation().head != NULL)
-               designator_shift_name();
-
        debug_enter();
 
        /*
@@ -1203,7 +1199,11 @@
 
 done_initstack:
        debug_initstack();
+
 done:
+       while (current_designation().head != NULL)
+               designator_shift_name();
+
        debug_leave();
 }
 



Home | Main Index | Thread Index | Old Index