lynx-dev
[Top][All Lists]
Advanced

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

lynx-dev Patch for atexit (dev.21) and DOS


From: Doug Kaufman
Subject: lynx-dev Patch for atexit (dev.21) and DOS
Date: Sun, 4 Apr 1999 22:36:34 -0700 (PDT)

The recent changes ifdef'ing LY_FIND_LEAKS by making atexit a no-op
function breaks the DOS port, since that port depends on atexit to
keep the DOS BREAK function properly set on exit. The following patch
puts back atexit, and ifdef's each place where atexit isn't needed
except when finding leaks.

I also included a long overdue DOS patch for LYMain.c, fixing the
determination of BREAK status to be independent of SLANG or PDCurses.

The patch was done on a DOS machine, with all long filenames restored
by hand. I hope there aren't any typos.

This was done against dev.21, with recent patches already applied, so
line numbers may not be exact against an unpatched dev.21
                                     Doug

--- lynx2-8-2/src/DefaultStyle.c        Tue Mar 30 09:10:38 1999
+++ lynx2-8-2/src/DefaultStyle.c.new    Sun Apr  4 19:39:42 1999
@@ -392,7 +392,9 @@
        result = HTStyleSheetNew ();
        *result = sheet;
        result->styles = 0;
+#ifdef LY_FIND_LEAKS
        atexit(FreeDefaultStyle);
+#endif
        for (p = sheet.styles; p != 0; p = p->next) {
            q = HTStyleNew ();
            *q = *p;
--- lynx2-8-2/src/GridText.c    Sun Apr  4 11:23:30 1999
+++ lynx2-8-2/src/GridText.c.new        Sun Apr  4 19:40:38 1999
@@ -432,7 +432,9 @@
 
     if (!loaded_texts) {
        loaded_texts = HTList_new();
+#ifdef LY_FIND_LEAKS
        atexit(free_all_texts);
+#endif
     }
 
     /*
@@ -5291,7 +5293,9 @@
 
     if (!search_queries) {
        search_queries = HTList_new();
+#ifdef LY_FIND_LEAKS
        atexit(HTSearchQueries_free);
+#endif
        HTList_addObject(search_queries, new);
        return;
     }
--- lynx2-8-2/WWW/Library/Implementation/HTAABrow.c     Thu Dec 24 03:27:24 1998
+++ lynx2-8-2/WWW/Library/Implementation/HTAABrow.c.new Sun Apr  4 19:14:22 1999
@@ -837,7 +837,9 @@
     **  Setup atexit() freeing if not done already. - FM
     */
     if (!free_HTAAGlobalsSet) {
+#ifdef LY_FIND_LEAKS
         atexit(free_HTAAGlobals);
+#endif
        free_HTAAGlobalsSet = TRUE;
     }
 
@@ -1065,7 +1067,9 @@
     **  Setup atexit() freeing if not done already. - FM
     */
     if (!free_HTAAGlobalsSet) {
+#ifdef LY_FIND_LEAKS
         atexit(free_HTAAGlobals);
+#endif
        free_HTAAGlobalsSet = TRUE;
     }
 
--- lynx2-8-2/WWW/Library/Implementation/HTAAProt.c     Tue Mar 30 09:10:38 1999
+++ lynx2-8-2/WWW/Library/Implementation/HTAAProt.c.new Sun Apr  4 19:16:00 1999
@@ -607,7 +607,9 @@
     if (!known_grp) {
        known_grp = HTList_new();
        if (!uidgid_cache_inited) {
+#ifdef LY_FIND_LEAKS
            atexit(clear_uidgid_cache);
+#endif
            uidgid_cache_inited = YES;
        }
     }
@@ -624,7 +626,9 @@
     if (!known_pwd) {
        known_pwd = HTList_new();
        if (!uidgid_cache_inited) {
+#ifdef LY_FIND_LEAKS
            atexit(clear_uidgid_cache);
+#endif
            uidgid_cache_inited = YES;
        }
     }
--- lynx2-8-2/WWW/Library/Implementation/HTAAUtil.c     Tue Mar 30 09:10:38 1999
+++ lynx2-8-2/WWW/Library/Implementation/HTAAUtil.c.new Sun Apr  4 19:16:50 1999
@@ -498,7 +498,9 @@
                                (size_t)(sizeof(char)*(buffer_length + 1)));
     }
     if (buffer == NULL) outofmem(__FILE__, "HTAA_setupReader");
+#ifdef LY_FIND_LEAKS
     atexit(FreeHTAAUtil);
+#endif
     start_pointer = buffer;
     if (start_of_headers) {
        strncpy(buffer, start_of_headers, length);
--- lynx2-8-2/WWW/Library/Implementation/HTAccess.c     Tue Mar 30 09:10:38 1999
+++ lynx2-8-2/WWW/Library/Implementation/HTAccess.c.new Sun Apr  4 19:18:44 1999
@@ -105,7 +105,9 @@
 {
     if (!protocols) {
        protocols = HTList_new();
+#ifdef LY_FIND_LEAKS
        atexit(free_protocols);
+#endif
     }
     HTList_addObject(protocols, protocol);
     return YES;
--- lynx2-8-2/WWW/Library/Implementation/HTAnchor.c     Tue Mar 30 09:10:38 1999
+++ lynx2-8-2/WWW/Library/Implementation/HTAnchor.c.new Sun Apr  4 19:11:06 1999
@@ -377,7 +377,9 @@
            adult_table = (HTList **)calloc(HASH_SIZE, sizeof(HTList *));
            if (!adult_table)
                outofmem(__FILE__, "HTAnchor_findAddress");
+#ifdef LY_FIND_LEAKS
            atexit(free_adult_table);
+#endif
        }
        if (!adult_table[hash])
            adult_table[hash] = HTList_new();
--- lynx2-8-2/WWW/Library/Implementation/HTAtom.c       Tue Mar 30 09:10:38 1999
+++ lynx2-8-2/WWW/Library/Implementation/HTAtom.c.new   Sun Apr  4 19:07:22 1999
@@ -54,7 +54,9 @@
        for (i = 0; i < HASH_SIZE; i++)
            hash_table[i] = (HTAtom *) 0;
        initialised = YES;
+#ifdef LY_FIND_LEAKS
        atexit(free_atoms);
+#endif
     }
 
     /*         Generate hash function
--- lynx2-8-2/WWW/Library/Implementation/HTFile.c       Sun Apr  4 11:28:32 1999
+++ lynx2-8-2/WWW/Library/Implementation/HTFile.c.new   Sun Apr  4 19:21:00 1999
@@ -457,7 +457,9 @@
            */
            if (!HTSuffixes)    {
                HTSuffixes = HTList_new();
+#ifdef LY_FIND_LEAKS
                atexit(free_suffixes);
+#endif
            }
 
            HTList_addObject(HTSuffixes, suff);
--- lynx2-8-2/WWW/Library/Implementation/HTFormat.c     Sun Apr  4 11:26:32 1999
+++ lynx2-8-2/WWW/Library/Implementation/HTFormat.c.new Sun Apr  4 19:22:12 1999
@@ -110,7 +110,9 @@
      */
     if (!HTPresentations)      {
        HTPresentations = HTList_new();
+#ifdef LY_FIND_LEAKS
        atexit(HTFreePresentations);
+#endif
     }
 
     if (strcmp(representation, "*")==0) {
@@ -153,7 +155,9 @@
      */
     if (!HTPresentations)      {
        HTPresentations = HTList_new();
+#ifdef LY_FIND_LEAKS
        atexit(HTFreePresentations);
+#endif
     }
 
     HTList_addObject(HTPresentations, pres);
--- lynx2-8-2/WWW/Library/Implementation/HTFTP.c        Tue Mar 30 09:10:38 1999
+++ lynx2-8-2/WWW/Library/Implementation/HTFTP.c.new    Sun Apr  4 18:55:06 1999
@@ -636,7 +636,9 @@
        /*
        **  Set up freeing at exit. - FM
        */
+#ifdef LY_FIND_LEAKS
        atexit(free_FTPGlobals);
+#endif
        firstuse = FALSE;
     }
 
--- lynx2-8-2/WWW/Library/Implementation/HTNews.c       Tue Mar 30 09:10:38 1999
+++ lynx2-8-2/WWW/Library/Implementation/HTNews.c.new   Sun Apr  4 19:23:40 1999
@@ -213,7 +213,9 @@
 #endif /* NeXTStep */
 
     s = -1;            /* Disconnected */
+#ifdef LY_FIND_LEAKS
     atexit(free_news_globals);
+#endif
     return YES;
 }
 
@@ -343,7 +345,9 @@
        }
     } else {
        NNTP_AuthInfo = HTList_new();
+#ifdef LY_FIND_LEAKS
        atexit(free_NNTP_AuthInfo);
+#endif
     }
 
     /*
--- lynx2-8-2/WWW/Library/Implementation/HTRules.c      Tue Mar 30 09:10:38 1999
+++ lynx2-8-2/WWW/Library/Implementation/HTRules.c.new  Sun Apr  4 19:24:26 1999
@@ -102,7 +102,9 @@
     }
 
     if (!rules) {
+#ifdef LY_FIND_LEAKS
        atexit(HTClearRules);
+#endif
     }
 #ifdef PUT_ON_HEAD
     temp->next = rules;
--- lynx2-8-2/WWW/Library/Implementation/HTTCP.c        Tue Mar 30 09:10:38 1999
+++ lynx2-8-2/WWW/Library/Implementation/HTTCP.c.new    Sun Apr  4 18:59:10 1999
@@ -1262,7 +1262,9 @@
        return;                         /* Already done */
     gethostname(name, namelength);     /* Without domain */
     StrAllocCopy(hostname, name);
+#ifdef LY_FIND_LEAKS
     atexit(free_HTTCP_hostname);
+#endif
 #ifdef UCX
     /*
     ** UCX doesn't give the complete domain name.
--- lynx2-8-2/src/LYCgi.c       Tue Mar 30 09:10:38 1999
+++ lynx2-8-2/src/LYCgi.c.new   Sun Apr  4 19:41:22 1999
@@ -91,7 +91,9 @@
 {
     if (!alloced) {
        alloced = HTList_new();
+#ifdef LY_FIND_LEAKS
        atexit(free_alloced_lynxcgi);
+#endif
     }
     HTList_addObject(alloced, ptr);
 }
--- lynx2-8-2/src/LYCookie.c    Tue Mar 30 09:10:38 1999
+++ lynx2-8-2/src/LYCookie.c.new        Sun Apr  4 19:42:14 1999
@@ -280,7 +280,9 @@
      * Ensure that the domain list exists.
      */
     if (domain_list == NULL) {
+#ifdef LY_FIND_LEAKS
        atexit(LYCookieJar_free);
+#endif
        domain_list = HTList_new();
        total_cookies = 0;
     }
@@ -2670,7 +2672,9 @@
      */
 
     if (domain_list == NULL) {
+#ifdef LY_FIND_LEAKS
        atexit(LYCookieJar_free);
+#endif
        domain_list = HTList_new();
        total_cookies = 0;
     }
--- lynx2-8-2/src/LYCurses.c    Sun Apr  4 11:21:40 1999
+++ lynx2-8-2/src/LYCurses.c.new        Sun Apr  4 13:29:18 1999
@@ -784,10 +784,8 @@
        parse_userstyles();
 #endif
        first_time = FALSE;
-#if USE_COLOR_TABLE
        lynx_init_colors();
        lynx_called_initscr = TRUE;
-#endif /* USE_COLOR_TABLE */
     }
 #ifdef __DJGPP__
     else sock_init();
--- lynx2-8-2/WWW/Library/Implementation/LYexit.h       Tue Mar 30 09:10:38 1999
+++ lynx2-8-2/WWW/Library/Implementation/LYexit.h.new   Sun Apr  4 18:34:00 1999
@@ -30,12 +30,8 @@
 
 #define exit LYexit
 
-#ifdef LY_FIND_LEAKS
 #define atexit LYatexit
 #define ATEXITSIZE 40
-#else
-#define atexit(func) /*nothing*/
-#endif
 
 /*
  *     Data structures
--- lynx2-8-2/src/LYexit.c      Tue Mar 30 09:10:38 1999
+++ lynx2-8-2/src/LYexit.c.new  Sun Apr  4 18:01:44 1999
@@ -19,7 +19,6 @@
  */
 PUBLIC BOOL LYOutOfMemory = FALSE;
 
-#ifdef LY_FIND_LEAKS
 
 /*
  *  Stack of functions to call upon exit.
@@ -78,9 +77,6 @@
        callstack[topOfStack]();
     }
 }
-#else
-#define LYCompleteExit() /*nothing*/
-#endif /* LY_FIND_LEAKS */
 
 /*
  *  Purpose:           Terminates program.
--- lynx2-8-2/src/LYGetFile.c   Sun Apr  4 11:29:40 1999
+++ lynx2-8-2/src/LYGetFile.c.new       Sun Apr  4 19:43:06 1999
@@ -1177,7 +1177,9 @@
     if (!src)
        return;
     if (first) {
+#ifdef LY_FIND_LEAKS
        atexit(LYTrusted_free);
+#endif
        first = FALSE;
     }
 
--- lynx2-8-2/src/LYHistory.c   Tue Mar 30 09:10:38 1999
+++ lynx2-8-2/src/LYHistory.c.new       Sun Apr  4 19:43:34 1999
@@ -95,7 +95,9 @@
 
     if (!Visited_Links) {
        Visited_Links = HTList_new();
+#ifdef LY_FIND_LEAKS
        atexit(Visited_Links_free);
+#endif
        HTList_addObject(Visited_Links, new);
        return;
     }
--- lynx2-8-2/src/LYMain.c      Sun Apr  4 11:12:18 1999
+++ lynx2-8-2/src/LYMain.c.new  Sun Apr  4 19:46:40 1999
@@ -30,6 +30,7 @@
 
 #ifdef __DJGPP__
 #include <dos.h>
+#include <dpmi.h>
 #endif /* __DJGPP__ */
 
 #ifdef __EMX__
@@ -437,11 +438,10 @@
 
 PRIVATE int LY_get_ctrl_break(void)
 {
-    typedef union REGS Regs;
-    extern Regs regs;
+    __dpmi_regs regs;
     regs.h.ah = 0x33;
     regs.h.al = 0x00;
-    int86(0x21, &regs, &regs);
+    __dpmi_int (0x21, &regs);
     return ((int) regs.h.dl);
 }
 
@@ -728,11 +728,12 @@
      * Will display memory leaks if LY_FIND_LEAKS is defined.
      */
     atexit(LYLeaks);
-#endif /* LY_FIND_LEAKS */
     /*
      * Register the function which will free our allocated globals.
      */
     atexit(free_lynx_globals);
+#endif /* LY_FIND_LEAKS */
+
 
 #ifdef LOCALE
     /*
@@ -1106,7 +1107,9 @@
 
                if (LYStdinArgs == NULL) {
                    LYStdinArgs = HTList_new();
+#ifdef LY_FIND_LEAKS
                    atexit(LYStdinArgs_free);
+#endif
                }
                StrAllocCopy(argument, buf);
                HTList_appendObject(LYStdinArgs, argument);
--- lynx2-8-2/src/LYMainLoop.c  Sun Apr  4 11:12:20 1999
+++ lynx2-8-2/src/LYMainLoop.c.new      Sun Apr  4 19:47:52 1999
@@ -318,7 +318,9 @@
                                       language : ""));
     StrAllocCopy(CurrentNegoCharset, (pref_charset ?
                                      pref_charset : ""));
+#ifdef LY_FIND_LEAKS
     atexit(free_mainloop_variables);
+#endif
 initialize:
     StrAllocCopy(newdoc.address, startfile);
     StrAllocCopy(startrealm, startfile);
@@ -6064,7 +6066,9 @@
 
     if (!Goto_URLs) {
        Goto_URLs = HTList_new();
+#ifdef LY_FIND_LEAKS
        atexit(HTGotoURLs_free);
+#endif
        HTList_addObject(Goto_URLs, new);
        return;
     }
--- lynx2-8-2/src/LYMap.c       Tue Mar 30 09:10:38 1999
+++ lynx2-8-2/src/LYMap.c.new   Sun Apr  4 19:48:32 1999
@@ -163,7 +163,9 @@
     {
        if (!LynxMaps) {
            LynxMaps = HTList_new();
+#ifdef LY_FIND_LEAKS
            atexit(LYLynxMaps_free);
+#endif
        }
        theList = LynxMaps;
     }
--- lynx2-8-2/src/LYReadCFG.c   Sun Apr  4 11:12:22 1999
+++ lynx2-8-2/src/LYReadCFG.c.new       Sun Apr  4 19:49:22 1999
@@ -143,7 +143,9 @@
        if (cur_item == NULL)
            outofmem(__FILE__, "read_cfg");
        *list_ptr = cur_item;
+#ifdef LY_FIND_LEAKS
        atexit(free_item_list);
+#endif
     } else {
        /*
         *  Find the last item.
@@ -241,7 +243,9 @@
        if (cur_item == NULL)
            outofmem(__FILE__, "read_cfg");
        *list_ptr = cur_item;
+#ifdef LY_FIND_LEAKS
        atexit(free_printer_item_list);
+#endif
     } else {
        /*
         *  Find the last item.
--- lynx2-8-2/src/LYStyle.c     Sun Apr  4 11:12:24 1999
+++ lynx2-8-2/src/LYStyle.c.new Sun Apr  4 19:50:10 1999
@@ -324,7 +324,9 @@
        }
        if (firsttime) {
            firsttime = 0;
+#ifdef LY_FIND_LEAKS
            atexit(free_colorstylestuff);
+#endif
        }
        s_high   = hash_code("high");
        s_alink  = hash_code("alink");
--- lynx2-8-2/src/LYUtils.c     Sun Apr  4 11:23:40 1999
+++ lynx2-8-2/src/LYUtils.c.new Sun Apr  4 19:51:10 1999
@@ -2437,7 +2437,9 @@
 
     if (!localhost_aliases) {
        localhost_aliases = HTList_new();
+#ifdef LY_FIND_LEAKS
        atexit(LYLocalhostAliases_free);
+#endif
     }
 
     if ((LocalAlias = (char *)calloc(1, (strlen(alias) + 1))) == NULL)
@@ -3063,7 +3065,9 @@
 
     if (!sug_filenames) {
        sug_filenames = HTList_new();
+#ifdef LY_FIND_LEAKS
        atexit(HTSugFilenames_free);
+#endif
        HTList_addObject(sug_filenames, new);
        return;
     }
@@ -4890,7 +4894,9 @@
            StrAllocCopy(HomeDir, cp);
        }
        homedir = (CONST char *)HomeDir;
+#ifdef LY_FIND_LEAKS
        atexit(LYHomeDir_free);
+#endif
     }
     return homedir;
 }
--- lynx2-8-2/src/UCdomap.c     Tue Mar 30 09:10:38 1999
+++ lynx2-8-2/src/UCdomap.c.new Sun Apr  4 19:52:02 1999
@@ -2024,7 +2024,9 @@
 {
 
     UCreset_allocated_LYCharSets();
+#ifdef LY_FIND_LEAKS
     atexit(UCcleanup_mem);
+#endif
     UCconsole_map_init();
 
 /*

__
Doug Kaufman
Internet: address@hidden (preferred)
          address@hidden


reply via email to

[Prev in Thread] Current Thread [Next in Thread]