Commit daad087227f3274549e9db3c8fac4e9e5ff3fb19

  • avatar
  • Petr Ovtchenkov (Committer)
  • Fri Aug 28 11:08:30 CEST 2009
  • avatar
  • David Deakins <DavidDeakins @gm…l.com> (Author)
  • Sun Aug 16 23:47:00 CEST 2009
Fixed debug chunk allocators for MSVC/_STLP_DEBUG_ALLOC.

The __stlp_new_void_chunk and __stlp_delete_chunk
functions are missing the _CRT_BLOCK argument in
their calls to ::operator new and ::operator delete.
Also the _STLP_CHECK_NULL_ALLOC macro inserts a return
keyword that causes the current implementation
of __stlp_new_void_chunk not to compile.

The _CRT_BLOCK arguments were added and
__stlp_new_void_chunk was broken up into two inline
functions, the first of which uses
_STLP_CHECK_NULL_ALLOC to return the new block
of memory to the second.
  
5757// memory leaks when run with debug CRT libraries.
5858#if defined (_STLP_MSVC) && (_STLP_MSVC >= 1020 && defined (_STLP_DEBUG_ALLOC)) && !defined (_STLP_WCE)
5959# include <crtdbg.h>
60inline void* __stlp_new_void_chunk(size_t __bytes) {
61 _STLP_CHECK_NULL_ALLOC(::operator new(__bytes, _CRT_BLOCK, __FILE__, __LINE__));
62}
6063inline char* __stlp_new_chunk(size_t __bytes) {
61 void *__chunk = _STLP_CHECK_NULL_ALLOC(::operator new(__bytes, __FILE__, __LINE__));
62 return __STATIC_CAST(char*, __chunk);
64 return __STATIC_CAST(char*, __stlp_new_void_chunk(__bytes));
6365}
64inline void __stlp_delete_chunck(void* __p) { ::operator delete(__p, __FILE__, __LINE__); }
66inline void __stlp_delete_chunck(void* __p) { ::operator delete(__p, _CRT_BLOCK, __FILE__, __LINE__); }
6567#else
6668# ifdef _STLP_NODE_ALLOC_USE_MALLOC
6769# include <cstdlib>