From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,2925b133078d1557 X-Google-Attributes: gid103376,public From: bobduff@world.std.com (Robert A Duff) Subject: Re: Flexible Strings (was Equality operator...) Date: 1997/05/07 Message-ID: #1/1 X-Deja-AN: 239847882 References: <9704301422.AA07755@most> <5kocg6$hln@bcrkh13.bnr.ca> Organization: The World Public Access UNIX, Brookline, MA Newsgroups: comp.lang.ada Date: 1997-05-07T00:00:00+00:00 List-Id: In article <5kocg6$hln@bcrkh13.bnr.ca>, Kaz Kylheku wrote: >But the C standard firmly says that ``The free function causes the space >pointed to by ptr to be deallocated, that is, made available for further >allocation'' (ISO 9899:1990 7.10.3.2 The free function). This pretty much >constitutes a requirement that the C implementation actually deallocate >when free is called, which carries more weight than a mere observation >about what all existing implementations do. It *sounds* firm, but it isn't really saying anything precise. For example, it doesn't address the issue of fragmentation. If I deallocate 1000 objects of size 100 bytes each, does that mean I can now allocate a single 100,000-byte object in that space? After all, it says that storage is "available for allocation". Do you interpret this requirement to require compaction of storage? Sure sounds like it, but that surely wasn't the intent. Can you write a test program that detects the difference between a C implementation that obeys the above "requirement", and one that doesn't? If not, then it should be viewed merely as Implementation Advice, from a formal point of view. Of course, I admit that the C standard is easier to understand on this particular point, if you're just a programmer trying to write programs, and not a language lawyer. The Ada standard goes out of its way to raise questions of this nature, unfortunately. Nonetheless, I claim that the requirements of C and Ada are identical with respect to whether free/Unch_Dealloc must/should reclaim storage. They're just written in a different style. - Bob