X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Fpublic-api%2Fcommon%2Fdali-vector.cpp;h=31fad54881573e9c539ba9584ae317a3ed23566a;hb=646f736e77b085c86e982c0d1d4b895c2a431330;hp=643c89f86ac70475d3abaf05f291f2d8bd4f43ba;hpb=c035b65926609db54d979cffaadaae22eec5864f;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/public-api/common/dali-vector.cpp b/dali/public-api/common/dali-vector.cpp index 643c89f..31fad54 100644 --- a/dali/public-api/common/dali-vector.cpp +++ b/dali/public-api/common/dali-vector.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,8 +19,7 @@ #include // EXTERNAL INCLUDES -#include -#include +#include // for memcpy & memmove namespace Dali { @@ -52,9 +51,8 @@ void VectorBase::Release() { // adjust pointer to real beginning SizeType* metadata = reinterpret_cast< SizeType* >( mData ); - // TODO would be nice to memset to a bitpattern to catch illegal use of container after release - // but that would require knowledge of the itemsize - free( metadata - 2u ); + + delete [] ( metadata - 2u ); mData = 0u; } } @@ -76,7 +74,9 @@ void VectorBase::Reserve( SizeType capacity, SizeType elementSize ) if( capacity > oldCapacity ) { const SizeType wholeAllocation = sizeof(SizeType) * 2u + capacity * elementSize; - void* wholeData = (void*)malloc( wholeAllocation ); + void* wholeData = reinterpret_cast< void* >( new uint8_t[ wholeAllocation ] ); + DALI_ASSERT_ALWAYS( wholeData && "VectorBase::Reserve - Memory allocation failed" ); + #if defined( DEBUG_ENABLED ) // in debug build this will help identify a vector of uninitialized data memset( wholeData, 0xaa, wholeAllocation );