X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fcommon%2Ffixed-size-memory-pool.h;h=6e05ffe3329c7d7f7d6502a5c7b3e3d68b96765e;hb=c8e0d2807617b0ba441ae67e735512bf6f3c1c68;hp=a3317ed63636d44fadd96b7f135297701a778e16;hpb=c6122991d434dc0a31787e61b21f059dbd72de37;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/common/fixed-size-memory-pool.h b/dali/internal/common/fixed-size-memory-pool.h index a3317ed..6e05ffe 100644 --- a/dali/internal/common/fixed-size-memory-pool.h +++ b/dali/internal/common/fixed-size-memory-pool.h @@ -1,8 +1,8 @@ -#ifndef __DALI_INTERNAL_FIXED_SIZE_MEMORY_POOL_H__ -#define __DALI_INTERNAL_FIXED_SIZE_MEMORY_POOL_H__ +#ifndef DALI_INTERNAL_FIXED_SIZE_MEMORY_POOL_H +#define DALI_INTERNAL_FIXED_SIZE_MEMORY_POOL_H /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -24,18 +24,16 @@ namespace Dali { - namespace Internal { - /** * @brief Calculate the size of a type taking alignment into account */ -template< typename T > +template struct TypeSizeWithAlignment { ///< The size of the type with alignment taken into account - static const size_t size = ( ( sizeof( T ) + sizeof( void* ) - 1 ) / sizeof( void* ) ) * sizeof( void* ); + static const size_t size = ((sizeof(T) + sizeof(void*) - 1) / sizeof(void*)) * sizeof(void*); }; /** @@ -52,11 +50,9 @@ struct TypeSizeWithAlignment class FixedSizeMemoryPool { public: - - typedef uint32_t SizeType; + using SizeType = uint32_t; public: - /** * @brief Constructor. * @@ -66,7 +62,7 @@ public: * @param maximumBlockCapacity The maximum size that a new block of memory can be allocated. Defaults to * a large value (1024 * 1024 = 1048576). */ - explicit FixedSizeMemoryPool( SizeType fixedSize, SizeType initialCapacity = 32, SizeType maximumBlockCapacity = 1048576 ); + explicit FixedSizeMemoryPool(SizeType fixedSize, SizeType initialCapacity = 32, SizeType maximumBlockCapacity = 1048576); /** * @brief Destructor. @@ -92,32 +88,36 @@ public: * * @param memory The memory to be deleted. Must have been allocated by this memory pool */ - void Free( void* memory ); + void Free(void* memory); /** * @brief Thread-safe version of Free() * * @param memory The memory to be deleted. Must have been allocated by this memory pool */ - void FreeThreadSafe( void* memory ); + void FreeThreadSafe(void* memory); -private: + /** + * Get the current capacity of the memory pool + * + * @note in release mode, this returns 0, as the block size isn't defined. + */ + uint32_t GetCapacity() const; +private: // Undefined - FixedSizeMemoryPool( const FixedSizeMemoryPool& fixedSizeMemoryPool ); + FixedSizeMemoryPool(const FixedSizeMemoryPool& fixedSizeMemoryPool); // Undefined - FixedSizeMemoryPool& operator=( const FixedSizeMemoryPool& fixedSizeMemoryPool ); + FixedSizeMemoryPool& operator=(const FixedSizeMemoryPool& fixedSizeMemoryPool); private: - struct Impl; Impl* mImpl; - }; } // namespace Internal } // namespace Dali -#endif /* __DALI_INTERNAL_FIXED_SIZE_MEMORY_POOL_H__ */ +#endif // DALI_INTERNAL_FIXED_SIZE_MEMORY_POOL_H