Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!lakesys!chad From: chad@lakesys.UUCP (D. Chadwick Gibbons) Newsgroups: comp.sources.games.bugs Subject: Re: What setbuf() is and why you should use it Keywords: curses fflush setbuf stdio Message-ID: <857@lakesys.UUCP> Date: 18 Jul 89 04:05:32 GMT References: <283@wet.UUCP> <2245@auspex.auspex.com> Reply-To: chad@lakesys.UUCP (D. Chadwick Gibbons) Organization: Lake Systems - Milwaukee, Wisconsin Lines: 17 In article <2245@auspex.auspex.com> guy@auspex.auspex.com (Guy Harris) writes: | |>The fix is very simple: put |> setbuf(stdout, malloc(BUFSIZ)); | |In which case, if you run out of e.g. swap space (or address space, |unless you've got tons of it and haven't consumed it all due to some |other bug), you may drop core. Uh, no. Sorry. Read the man page for setbuf a little better. malloc() returns NULL when it can't allocate the memory, right? If the second argument to setbuf is NULL, buffering will be turned off. No dumping core, just a straight through output mechanism-which might be nice to have considering your program can't allocate memory and it is early on in the game. -- D. Chadwick Gibbons, chad@lakesys.lakesys.com, ...!uunet!marque!lakesys!chad