Aduke.1449 net.news utzoo!decvax!duke!swd Fri Dec 4 10:09:07 1981 Re: sdcarl.108: BUFLEN Why not malloc a buffer? When the 'A' version of news was designed, we attempted to write clean, portable, small code. We also attempted to put in sufficiently many error checks to prevent nasty core dump messages. Whether or not we succeded, our goals lead us to reject the use of malloc(3). There are several reasons. The first is speed: the sbrk system call can take a long time. Also, for small systems, being able to say 'size news' and know how large the program *really* is is important. I suspect that the code required to guess at the proper size of buffer, and the when it finds that the line it just tried to read (and only got the begining of) won't fit in its buffer, allocate a bigger buffer (how big?), copy the old one and read some more, would be bigger than just having larger static buffers, and a lot slower. Also, what happens when malloc fails for lack of memory? It can be very messy to clean up and recover gracefully, particularly since your stack may choose that precise moment to need to be expanded (oops!). ----------------------------------------------------------------- gopher://quux.org/ conversion by John Goerzen of http://communication.ucsd.edu/A-News/ This Usenet Oldnews Archive article may be copied and distributed freely, provided: 1. There is no money collected for the text(s) of the articles. 2. The following notice remains appended to each copy: The Usenet Oldnews Archive: Compilation Copyright (C) 1981, 1996 Bruce Jones, Henry Spencer, David Wiseman.