Article View: news.software.readers
Article #1581Re: ANNOUNCEMENT: Tin v1.1 PL3 newsreader posted to alt.sources
From: T. William Wells
Date: Mon, 18 May 1992 14:42
Date: Mon, 18 May 1992 14:42
36 lines
2190 bytes
2190 bytes
In article <1992May16.231811.19548@atlantis.uucp> bugs@atlantis.uucp (Dan Berry) writes:
: "AAAARGH!" cried the SysAdmin in horrified shock. "She be broke!"
:
: I've run into various problems that, quite simply, didn't exist in PL2 -- such
: as when quitting from the group selection screen, I get problems with
: unallocated memory attempting to be relocated or reallocated. That's the most
: obvious problem.
:
: Anyone else come across this (running NeXTstep 2.1)? I'm trying to hack away
: at the code, but I'm not much closer than when I started.
Sounds to me like someone was working from a man page that said
that you can realloc after freeing or like someone thought they
could access memory once it has been freed.
The bottom line is that, for portability, once you free something,
it is GONE. Don't realloc, don't malloc and hope you'll get it
back, and don't try this favored trick:
for (ptr = list; ptr; ptr = ptr->next) {
free(ptr);
}
The third expression accesses the memory that USED TO BE pointed
to by ptr; by the time the ptr = ptr->next gets executed, free
may have trashed all that memory.
Other goodies: don't realloc with a null pointer. Don't malloc
with size 0. Do not assume that a realloc that *shrinks* memory
will always succeed. For that matter, never assume that any call
to malloc/realloc will succeed; lot's of programmers do. Sigh.
---
Bill { uunet | decwrl | telesci }!twwells!bill
bill@twwells.com
Technical Details
Message-ID:
<BoGBJA.B7v@twwells.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-comp.sources.d.mbox.zip!sparky!uunet!decwrl!twwells!billReferences:
<1992May13.162355.16809@anl433.uucp> <1992May16.231811.19548@atlantis.uucp>Show Full Headers
Complete Article Headers
Message-ID: <BoGBJA.B7v@twwells.com> Subject: Re: ANNOUNCEMENT: Tin v1.1 PL3 newsreader posted to alt.sources Date: Mon, 18 May 1992 14:42:43 GMT From: bill@twwells.com (T. William Wells) References: <1992May13.162355.16809@anl433.uucp> <1992May16.231811.19548@atlantis.uucp> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-comp.sources.d.mbox.zip!sparky!uunet!decwrl!twwells!bill Newsgroups: news.software.readers,alt.sources.d,comp.sources.d Organization: None, Mt. Laurel, NJ Lines: 35