From 1348414663939835343
X-Google-Thread: f78e5,a10702d4a7db0a94
X-Google-Attributes: gidf78e5,public
X-Google-Language: ENGLISH,ASCII
Path: g2news2.google.com!news3.google.com!news.glorb.com!news.alt.net!comp-std-cpp-robomod!not-for-mail
From: "James Kanze" <james.kanze@gmail.com>
Newsgroups: comp.std.c++
Subject: Re: Why no size_t to ::operator delete?
Date: Wed,  3 Jan 2007 09:31:23 CST
Organization: http://groups.google.com
Lines: 36
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
Message-ID: <1167821807.522004.175740@k21g2000cwa.googlegroups.com>
References: <12omt8jit7rl379@corp.supernews.com>
   <memo.20061230111944.1648C@brangdon.cix.compulink.co.uk>
   <12pj4bamfkm0791@corp.supernews.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 8bit
X-Trace: posting.google.com 1167821811 24465 127.0.0.1 (3 Jan 2007 10:56:51 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Wed, 3 Jan 2007 10:56:51 +0000 (UTC)
Return-Path: <devnull@stump.algebra.com>
X-Authentication-Warning: mulga.csse.unimelb.edu.au: fjh set sender to devnull@stump.algebra.com using -f
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-Original-To: std-c++@mailman.ucar.edu
Delivered-To: std-c++@mailman.ucar.edu
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:1.0.1) Gecko/20020920 Netscape/7.0,gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: k21g2000cwa.googlegroups.com; posting-host=62.160.54.162;
   posting-account=uN4QgA0AAAC_qk3WofNKjyjXNSBMXL2b
X-Virus-Scanned: amavisd-new at ucar.edu
X-Virus-Scanned: amavisd-new at csse.unimelb.edu.au
X-MIME-Autoconverted: from quoted-printable to 8bit by mulga.csse.unimelb.edu.au id l03AuvmX006676
X-Virus-Scanned: amavisd-new at csse.unimelb.edu.au
Xref: g2news2.google.com comp.std.c++:5242

Scott Meyers wrote:
> Dave Harris wrote:
> > With a scheme like that, can't you use:

> >     static char *s_top; // Initialise to heap somehow.

> >     void *operator new( size_t sz ) {
> >         void *result = s_top;
> >         s_top += sz;
> >         return result;
> >     }

> >     void operator delete( void *p ) {
> >         if (p)
> >             s_top = reinterpret_cast<char *>( p );
> >     }

> I can't think of any reason why this wouldn't work in this case.

Alignment.  But that's easy to fix (and may not be a problem, if
all of the allocated objects are of types which have a size
which is a multiple of the maximum alignment).

--
James Kanze (GABI Software)             email:james.kanze@gmail.com
Conseils en informatique orient�e objet/
                   Beratung in objektorientierter Datenverarbeitung
9 place S�mard, 78210 St.-Cyr-l'�cole, France, +33 (0)1 30 23 00 34


---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]



