www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1999/04/08/13:53:46

Message-Id: <m10VIz0-000S74C@inti.gov.ar>
Comments: Authenticated sender is <salvador AT natacha DOT inti DOT gov DOT ar>
From: "Salvador Eduardo Tropea (SET)" <salvador AT inti DOT gov DOT ar>
Organization: INTI
To: djgpp-workers AT delorie DOT com
Date: Thu, 8 Apr 1999 14:56:57 +0000
MIME-Version: 1.0
Subject: Proposed patch to exit()
X-mailer: Pegasus Mail for Windows (v2.54)
Reply-To: djgpp-workers AT delorie DOT com

Hi All:

  The following patch is cosmetic but I think is good.
  It just calls free in exit to de-allocate all the memory allocated by the
atexit() function. I know that's not necesary because we will release all
when leaving the control to the OS but it helps to track memory leaks. My
editor is registering 23 functions with atexit and they are reported all the
time by YAMD. Of course I can remove these entries from the report using
a script but I think that's the best.

SET

--- src/libc/ansi/stdlib/exit.c~	Wed Apr  7 20:30:34 1999
+++ src/libc/ansi/stdlib/exit.c	Wed Apr  7 20:30:34 1999
@@ -25,14 +25,16 @@
 exit(int status)
 {
   int i;
-  struct __atexit *a;
+  struct __atexit *a,*o;
 
   a = __atexit_ptr;
   __atexit_ptr = 0; /* to prevent infinite loops */
   while (a)
   {
     (a->__function)();
+    o = a;
     a = a->__next;
+    free(o);
   }
 
   /* Destructors should probably be called after functions registered
------------------------------------ 0 --------------------------------
Visit my home page: http://welcome.to/SetSoft
or
http://www.geocities.com/SiliconValley/Vista/6552/
Salvador Eduardo Tropea (SET). (Electronics Engineer)
Alternative e-mail: set-soft AT usa DOT net set AT computer DOT org
ICQ: 2951574
Address: Curapaligue 2124, Caseros, 3 de Febrero
Buenos Aires, (1678), ARGENTINA
TE: +(5411) 4759 0013

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019