🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #4071

Re: Is malloc()ed storage freed upon program termination?

#4071
From: Mark Brader
Date: Thu, 21 Sep 1995 04:37
28 lines
1765 bytes
> I'm not sure I agree that it's an OS issue.  Shouldn't the standard define
> my responsibilities as a programmer if I want to write a portable program?

Yes, and so it does.  Right up to the moment when the program terminates.
It would be inappropriate for a language standard to specify that, if the
program is being run under an operating system, then the operating system
should do what it is supposed to.

> For example, the standard says that open streams are closed on
> program termination (AFTER it says that unwritten data is flushed).
> Why was it necessary to say that?

It wasn't.

> Even in this thread, there is not general agreement whether it's
> safe to end the program without freeing storage.

It won't break anything in the program if you don't; that's all that the
C standard can guarantee.  The nature of an operating system is what
guarantees the rest.  However, it is a fact of life that guarantees,
implicit or otherwise, are sometimes broken, and sometimes you have to
program around the bugs in your environment.
-- 
Mark Brader, msb@sq.com, SoftQuad Inc., Toronto
        "I'm a little worried about the bug-eater," she said.  "We're embedded
        in bugs, have you noticed?"             -- Niven, "The Integral Trees"

My text in this article is in the public domain.
Technical Details
Message-ID: <1995Sep21.043705.15949@sq.com>
Path: arc1-ca.pugleaf.net!howland.reston.ans.net!torn!sq!msb
References: <43l16d$3dp@homer.alpha.net> <811549923.10778@contech.demon.co.uk> <43pdon$b3i@rdsunx.crd.ge.com> <43prn7$h0@homer.alpha.net>

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c
Path: arc1-ca.pugleaf.net!howland.reston.ans.net!torn!sq!msb
From: msb@sq.com (Mark Brader)
Subject: Re: Is malloc()ed storage freed upon program termination?
Message-ID: <1995Sep21.043705.15949@sq.com>
Organization: SoftQuad Inc., Toronto, Canada
References: <43l16d$3dp@homer.alpha.net> <811549923.10778@contech.demon.co.uk> <43pdon$b3i@rdsunx.crd.ge.com> <43prn7$h0@homer.alpha.net>
Date: Thu, 21 Sep 1995 04:37:05 GMT