
On 12/22/05 10:45 AM, "Gennadiy Rozental" <gennadiy.rozental@thomson.com> wrote: [Markus Schöpflin <markus.schoepflin@comsoft.de> wrote:] [SNIP]
This ignores the fact the std::malloc() is allowed to return either 0 or some unique pointer on zero sized requests, whereas a C++ allocation function _must_ return a unique pointer for each zero sized request.
If I'm correct, this could be easily fixed by changing all occurences of "p = std::malloc(n)" to "p = std::malloc(n ? n : 1)" or something similar.
Ok. Applied.
Shouldn't it be applied only if std::malloc returns NULL on 0-sized allocations? A std::malloc implementation that returns unique pointers for zero sizes is OK. Maybe something like: void * p = std::malloc( n ); if ( !n && !p ) p = std::malloc( 1 ); return p; would be better? -- Daryle Walker Mac, Internet, and Video Game Junkie darylew AT hotmail DOT com