On Feb 13, 11:19 pm, Tristan Wibberley <maihem-...@maihem.orgwrote:
On Wed, 2008-02-13 at 15:42 -0500, Victor Bazarov wrote:
Well, malloc and calloc are just 'new char[]' and 'new char[]()'.
They don't "reserve raw memory" since there is no "raw memory" in
C++.
does new char[] give memory aligned appropriately for any type?
Yes. IMHO, however, it still gives the wrong signal to a reader
of the code. You don't want an array of char, you want raw
memory. (The standard just calls it "storage", but "raw memory"
is the usual term in less formal circles.) The standard also
defines a new expression as doing to things: calling an
allocator function to allocate the (raw) memory, and
initializing the object(s) in that memory. The "name" of that
allocator function is "operator new()". And that's exactly what
I use if I need raw memory.
Note that in C++, the only thing you can do with raw memory *is*
initialize it (or free it without using it).
--
James Kanze (GABI Software) email:ja*********@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