🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #3190

Re: Porting UNIX apps. to MS-DOS

#3190
From: REIDMP
Date: Sat, 03 Nov 1990 15:41
27 lines
1869 bytes
If you have lots of memory to play with for code space, one really
simple solution to try is to make as many of the functions inline
as possible.  Another simple fix that might work with TC (I can't
recall for sure how the compiler treats variable declarations, but
this works on many ANSI C compilers), is to delay declarations until
the block you will use the variable in.  Example:
     Before:                     After:
     void foo(char * s) {        void foo(char * s) {
     int i;                      if (s) {
     if (s) {                      int i;
       i = 1;                      i = 1;
     }                           }
     ...                         ...
     }                           }
 
The example is very simple and brain-dead, but the point is this: since
variables reside (mostly) on the stack, and (generally) live until the
end of the block of their declaration, push them further down into the
nested blocks, particularly if the variables sometimes won't be used.
This way you shorten the average life of data on the stack and sometimes
avoid unused variables ever being created.  With deeply nested recursion
this can make a difference.  However, this will only work if the compiler
doesn't optimize out the declaration to do one single stack adjustment
when the function is entered.
 
ciao for now
   Reid
Technical Details
Message-ID: <90307.104128REIDMP@MAINE.BITNET>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!att!dptg!ulysses!andante!mit-eddie!wuarchive!zaphod.mps.ohio-state.edu!think.com!yale!venus!yalevm!maine!reidmp
References: <90296.205211DLV101@psuvm.psu.edu> <1990Oct26.223541.26634@NCoast.ORG> <9449@jarthur.Claremont.EDU>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!att!dptg!ulysses!andante!mit-eddie!wuarchive!zaphod.mps.ohio-state.edu!think.com!yale!venus!yalevm!maine!reidmp
From: REIDMP@MAINE.BITNET
Newsgroups: comp.os.msdos.programmer
Subject: Re: Porting UNIX apps. to MS-DOS
Message-ID: <90307.104128REIDMP@MAINE.BITNET>
Date: 3 Nov 90 15:41:28 GMT
References: <90296.205211DLV101@psuvm.psu.edu> <1990Oct26.223541.26634@NCoast.ORG> <9449@jarthur.Claremont.EDU>
Organization: University of Maine System
Lines: 27