
23 Jul
2010
23 Jul
'10
8:49 p.m.
AMDG Christian Holmquist wrote:
The following doesn't look correct to me: If pool.allocate() is not supposed to throw an exception, you're constructing a node on a null pointer.
node * alloc_node(void) { node * chunk = pool.allocate(); new(chunk) node(); <---------- chunk may be 0? return chunk; }
It's okay if chunk is zero. Placement new is declared with throw(), so according to (5.3.4/13) it indicates failure by returning a null pointer, and the constructor will not be called. In Christ, Steven Watanabe