From cf9a910a8ac380ded3fb4b0d8ff9ecf3cf00c078 Mon Sep 17 00:00:00 2001 From: dbv Date: Wed, 21 Mar 2012 15:16:30 +0400 Subject: [PATCH] 0023033: Standard_MMgrOpt::Reallocate behavior must be similar to "realloc" Changes : Standard_MMgrOpt::Reallocate has been modified to allocate new memory block if NULL pointer has been passed. --- src/Standard/Standard_MMgrOpt.cxx | 6 ++++++ src/Standard/Standard_MMgrOpt.hxx | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Standard/Standard_MMgrOpt.cxx b/src/Standard/Standard_MMgrOpt.cxx index bcb39e139c..ce8751a611 100755 --- a/src/Standard/Standard_MMgrOpt.cxx +++ b/src/Standard/Standard_MMgrOpt.cxx @@ -718,6 +718,12 @@ void Standard_MMgrOpt::FreePools() Standard_Address Standard_MMgrOpt::Reallocate(Standard_Address& theStorage, const Standard_Size theNewSize) { + // if theStorage == NULL, just allocate new memory block + if (!theStorage) + { + return Allocate(theNewSize); + } + Standard_Size * aBlock = GET_BLOCK(theStorage); Standard_Address newStorage = NULL; diff --git a/src/Standard/Standard_MMgrOpt.hxx b/src/Standard/Standard_MMgrOpt.hxx index d7a626c3f1..dcbcb4e3d7 100755 --- a/src/Standard/Standard_MMgrOpt.hxx +++ b/src/Standard/Standard_MMgrOpt.hxx @@ -104,7 +104,8 @@ class Standard_MMgrOpt : public Standard_MMgrRoot //! Allocate aSize bytes; see class description above Standard_EXPORT virtual Standard_Address Allocate(const Standard_Size aSize); - //! Reallocate previously allocated aPtr to a new size; aPtr is nullified + //! Reallocate previously allocated aPtr to a new size; aPtr is nullified. + //! In case that aPtr is null, the function behaves exactly as Allocate. Standard_EXPORT virtual Standard_Address Reallocate(Standard_Address& aPtr, const Standard_Size aSize);