/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
{
// Memory pool used to allocate new nodes. Memory used by this pool will be released when process dies
// or DALI library is unloaded
-Dali::Internal::MemoryPoolObjectAllocator<Dali::Internal::SceneGraph::Node> gNodeMemoryPool;
+Dali::Internal::MemoryPoolObjectAllocator<Dali::Internal::SceneGraph::Node>& GetNodeMemoryPool()
+{
+ static Dali::Internal::MemoryPoolObjectAllocator<Dali::Internal::SceneGraph::Node> gNodeMemoryPool;
+ return gNodeMemoryPool;
+}
#ifdef DEBUG_ENABLED
// keep track of nodes alive, to ensure we have 0 when the process exits or DALi library is unloaded
int32_t gNodeCount = 0;
Node* Node::New()
{
- return new(gNodeMemoryPool.AllocateRawThreadSafe()) Node;
+ return new(GetNodeMemoryPool().AllocateRawThreadSafe()) Node;
}
void Node::Delete(Node* node)
node->~Node();
// Mark the memory it used as free in the memory pool
- gNodeMemoryPool.FreeThreadSafe(node);
+ GetNodeMemoryPool().FreeThreadSafe(node);
}
else
{
uint32_t Node::GetMemoryPoolCapacity()
{
- return gNodeMemoryPool.GetCapacity();
+ return GetNodeMemoryPool().GetCapacity();
}
} // namespace SceneGraph