[Tizen] Not execute the remove callback
[platform/core/uifw/dali-core.git] / dali / internal / common / const-string.cpp
index 486fcf9..f9e7f31 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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 <cstddef>
 #include <cstring>
 #include <functional>
-#include <vector>
 #include <mutex>
+#include <vector>
+
+// INTERNAL INCLUDES
+#include <dali/public-api/common/dali-common.h>
 
 // local namespace
 namespace
 {
 class ArenaAllocator
 {
-
 public:
   ArenaAllocator()
   {
@@ -155,7 +157,7 @@ public:
     const std::lock_guard<std::mutex> lock(mMutex);
 
     auto  bucketNumber = FindBucket(str);
-    auto& bucket   = mTable[bucketNumber];
+    auto& bucket       = mTable[bucketNumber];
 
     if(bucket)
     {
@@ -188,17 +190,19 @@ private:
      * So we allocate one memory and treat 1st segment as a array of StringEntry* and the second segment as array of
      * unsigned*.
      */
-    mTable              = static_cast<StringEntry**>(calloc(newBuckets + 1, sizeof(StringEntry**) + sizeof(unsigned)));
-    mBuckets            = newBuckets;
+    mTable = static_cast<StringEntry**>(calloc(newBuckets + 1, sizeof(StringEntry**) + sizeof(unsigned)));
+    DALI_ASSERT_ALWAYS(mTable && "calloc returned nullptr");
+
+    mBuckets = newBuckets;
   }
 
   unsigned FindBucket(std::string_view name)
   {
-    unsigned  bucketSize    = mBuckets;
-    unsigned  fullHashValue = std::hash<std::string_view>{}(name);
-    unsigned  bucketNumber      = fullHashValue & (bucketSize - 1);
+    unsigned bucketSize    = mBuckets;
+    unsigned fullHashValue = std::hash<std::string_view>{}(name);
+    unsigned bucketNumber  = fullHashValue & (bucketSize - 1);
     // point to the start of the hashvalue segment.
-    unsigned* hashTable     = reinterpret_cast<unsigned*>(mTable + mBuckets + 1);
+    unsigned* hashTable = reinterpret_cast<unsigned*>(mTable + mBuckets + 1);
 
     unsigned probeAmt = 1;
     while(true)
@@ -244,8 +248,11 @@ private:
       return bucketNumber;
     }
     unsigned newBucketNumber = bucketNumber;
+
     // Allocate one extra bucket which will always be non-empty.
     auto newTable = static_cast<StringEntry**>(calloc(newSize + 1, sizeof(StringEntry*) + sizeof(unsigned)));
+    DALI_ASSERT_ALWAYS(newTable && "calloc returned nullptr");
+
     // point to the start of the hashvalue segment. as the pointer is of type StringEntry* , but the
     // second segment keeps only unsigned data hence the reinterpret_cast.
     unsigned* newHashTable = reinterpret_cast<unsigned*>(newTable + newSize + 1);
@@ -320,4 +327,4 @@ void Dali::Internal::ConstString::SetString(std::string_view str)
   {
     mString = StringPool::Instance().Intern(str);
   }
-}
\ No newline at end of file
+}