/*
- * 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.
#include <dali/public-api/common/dali-vector.h>
// EXTERNAL INCLUDES
-#include <stdlib.h>
-#include <memory.h>
+#include <cstring> // for memcpy & memmove
namespace Dali
{
{
// 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;
}
}
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 );