🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #1956

Re: Why not op delete(void* v&,size_t);?

#1956
From: Todd Blanchard
Date: Wed, 13 Sep 1995 03:12
69 lines
3260 bytes
Don Organ (dorgan@megatest.com) wrote:

: > Steve Clamage (stephen.clamage@eng.sun.com) wrote:
: > 
: > Except in this case, the approach had been discussed years ago and rejected
: > as not a good idea. See D&E, for example.

Todd Replies:  Its not there.  Got a page#?

: > 
: > I recommend that you do a minimum of research before accusing others
: > of laziness and mendacity.
: > 
: > ---
: > Steve Clamage, stephen.clamage@eng.sun.com

: I think the original question may have been slightly confusing.
: It showed
:      void operator delete (void*& p, size_t s)
: I think it was intended to be
:      void operator delete (void*& p)
: In D&E I found an answer to why the 2nd argument to delete is illegal.

Actually, as I did a minimum of research before posting this question,
you can find the full explanation of how to overload op delete on page
283 of the ARM which allows for both 

void operator delete(void*);
and
void operator delete(void*,size_t);

Meyers explains in item 10 ("Effective C++" for the unfamiliar) that the
second version is useful in the event of inheritance.  It allows you to
tell if you are being asked to delete the base class or some (larger) 
derived class.  If you didn't have a custom new for the derived class, and
you wrote the correct new in the base class, you need to check the size and
perform either the custom delete or the global delete depending on the size
of the object.

Nowhere can I find a rational explanation for why the pointer is not
passed as a void*& (to allow zeroing).  It would provide more 
flexibility in memory management schemes.

: What is the answer to the question:
:      why the 1st (only) argument must be void* and can't be void*&?
: From the original posting, the intention seems clear to allow the
: delete operator to assign 0 to the pointer passed as the
: argument (i.e. the pointer must be passed by reference, not by value).

: I did a minimum of research - but didn't find an answer in D&E.
: (And I've lost my ARM!)
: Could someone point me to the exact page in D&E (or ARM or anywhere)
: or post a rationale?

: Thanks.

: Don Organ

--
-----------------------------------------------------------------------
Todd Blanchard                                    tblancha@evolving.com
Evolving Systems Inc.                               VOX: (303) 689-1798
                                                    FAX: (303) 689-1399
"Never underestimate the power of stupid people in large groups."
-----------------------------------------------------------------------
---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
 Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
 is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID: <434me4$ov3@citadel.evolving.com>
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back
References: <9509082051.AA01889@dawn.megaeng>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back
Date: 13 Sep 95 03:12:50 GMT
Approved: fjh@cs.mu.oz.au
From: tblancha@evolving.com (Todd Blanchard)
Newsgroups: comp.std.c++
Subject: Re: Why not op delete(void* v&,size_t);?
X-Original-Date: 12 Sep 1995 19:18:28 GMT
Organization: Evolving Systems, Inc.
Message-ID: <434me4$ov3@citadel.evolving.com>
References: <9509082051.AA01889@dawn.megaeng>
X-Newsreader: TIN [version 1.2 PL2]