Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'intern/guardedalloc')
-rw-r--r--intern/guardedalloc/CMakeLists.txt1
-rw-r--r--intern/guardedalloc/MEM_guardedalloc.h2
-rw-r--r--intern/guardedalloc/intern/leak_detector.cc4
-rw-r--r--intern/guardedalloc/intern/mallocn.c2
-rw-r--r--intern/guardedalloc/intern/mallocn_guarded_impl.c18
-rw-r--r--intern/guardedalloc/intern/mallocn_lockfree_impl.c10
-rw-r--r--intern/guardedalloc/tests/guardedalloc_alignment_test.cc2
7 files changed, 20 insertions, 19 deletions
diff --git a/intern/guardedalloc/CMakeLists.txt b/intern/guardedalloc/CMakeLists.txt
index 89fdf367037..0d16879adb5 100644
--- a/intern/guardedalloc/CMakeLists.txt
+++ b/intern/guardedalloc/CMakeLists.txt
@@ -7,6 +7,7 @@ endif()
set(INC
.
+ ..
../atomic
)
diff --git a/intern/guardedalloc/MEM_guardedalloc.h b/intern/guardedalloc/MEM_guardedalloc.h
index fdd77fb9eef..5ae33343949 100644
--- a/intern/guardedalloc/MEM_guardedalloc.h
+++ b/intern/guardedalloc/MEM_guardedalloc.h
@@ -271,7 +271,7 @@ void MEM_use_guarded_allocator(void);
template<typename T, typename... Args>
inline T *MEM_new(const char *allocation_name, Args &&...args)
{
- void *buffer = MEM_mallocN(sizeof(T), allocation_name);
+ void *buffer = MEM_mallocN_aligned(sizeof(T), alignof(T), allocation_name);
return new (buffer) T(std::forward<Args>(args)...);
}
diff --git a/intern/guardedalloc/intern/leak_detector.cc b/intern/guardedalloc/intern/leak_detector.cc
index 48df71e410d..5b565b15920 100644
--- a/intern/guardedalloc/intern/leak_detector.cc
+++ b/intern/guardedalloc/intern/leak_detector.cc
@@ -36,12 +36,12 @@ class MemLeakPrinter {
const size_t mem_in_use = MEM_get_memory_in_use();
printf("Error: Not freed memory blocks: %u, total unfreed memory %f MB\n",
leaked_blocks,
- (double)mem_in_use / 1024 / 1024);
+ double(mem_in_use) / 1024 / 1024);
MEM_printmemlist();
if (fail_on_memleak) {
/* There are many other ways to change the exit code to failure here:
- * - Make the destructor noexcept(false) and throw an exception.
+ * - Make the destructor `noexcept(false)` and throw an exception.
* - Call exit(EXIT_FAILURE).
* - Call terminate().
*/
diff --git a/intern/guardedalloc/intern/mallocn.c b/intern/guardedalloc/intern/mallocn.c
index 63f06ced31d..984e641e7c1 100644
--- a/intern/guardedalloc/intern/mallocn.c
+++ b/intern/guardedalloc/intern/mallocn.c
@@ -43,7 +43,7 @@ void (*MEM_set_error_callback)(void (*func)(const char *)) = MEM_lockfree_set_er
bool (*MEM_consistency_check)(void) = MEM_lockfree_consistency_check;
void (*MEM_set_memory_debug)(void) = MEM_lockfree_set_memory_debug;
size_t (*MEM_get_memory_in_use)(void) = MEM_lockfree_get_memory_in_use;
-unsigned int (*MEM_get_memory_blocks_in_use)(void) = MEM_lockfree_get_memory_blocks_in_use;
+uint (*MEM_get_memory_blocks_in_use)(void) = MEM_lockfree_get_memory_blocks_in_use;
void (*MEM_reset_peak_memory)(void) = MEM_lockfree_reset_peak_memory;
size_t (*MEM_get_peak_memory)(void) = MEM_lockfree_get_peak_memory;
diff --git a/intern/guardedalloc/intern/mallocn_guarded_impl.c b/intern/guardedalloc/intern/mallocn_guarded_impl.c
index cd4b99ecde8..8deeb862b35 100644
--- a/intern/guardedalloc/intern/mallocn_guarded_impl.c
+++ b/intern/guardedalloc/intern/mallocn_guarded_impl.c
@@ -144,7 +144,7 @@ static const char *check_memlist(MemHead *memh);
/* vars */
/* --------------------------------------------------------------------- */
-static unsigned int totblock = 0;
+static uint totblock = 0;
static size_t mem_in_use = 0, peak_mem = 0;
static volatile struct localListBase _membase;
@@ -453,7 +453,7 @@ void *MEM_guarded_mallocN(size_t len, const char *str)
print_error("Malloc returns null: len=" SIZET_FORMAT " in %s, total %u\n",
SIZET_ARG(len),
str,
- (unsigned int)mem_in_use);
+ (uint)mem_in_use);
return NULL;
}
@@ -467,7 +467,7 @@ void *MEM_guarded_malloc_arrayN(size_t len, size_t size, const char *str)
SIZET_ARG(len),
SIZET_ARG(size),
str,
- (unsigned int)mem_in_use);
+ (uint)mem_in_use);
abort();
return NULL;
}
@@ -526,7 +526,7 @@ void *MEM_guarded_mallocN_aligned(size_t len, size_t alignment, const char *str)
print_error("aligned_malloc returns null: len=" SIZET_FORMAT " in %s, total %u\n",
SIZET_ARG(len),
str,
- (unsigned int)mem_in_use);
+ (uint)mem_in_use);
return NULL;
}
@@ -550,7 +550,7 @@ void *MEM_guarded_callocN(size_t len, const char *str)
print_error("Calloc returns null: len=" SIZET_FORMAT " in %s, total %u\n",
SIZET_ARG(len),
str,
- (unsigned int)mem_in_use);
+ (uint)mem_in_use);
return NULL;
}
@@ -564,7 +564,7 @@ void *MEM_guarded_calloc_arrayN(size_t len, size_t size, const char *str)
SIZET_ARG(len),
SIZET_ARG(size),
str,
- (unsigned int)mem_in_use);
+ (uint)mem_in_use);
abort();
return NULL;
}
@@ -606,7 +606,7 @@ void MEM_guarded_printmemlist_stats(void)
{
MemHead *membl;
MemPrintBlock *pb, *printblock;
- unsigned int totpb, a, b;
+ uint totpb, a, b;
size_t mem_in_use_slop = 0;
mem_lock_thread();
@@ -1177,9 +1177,9 @@ size_t MEM_guarded_get_memory_in_use(void)
return _mem_in_use;
}
-unsigned int MEM_guarded_get_memory_blocks_in_use(void)
+uint MEM_guarded_get_memory_blocks_in_use(void)
{
- unsigned int _totblock;
+ uint _totblock;
mem_lock_thread();
_totblock = totblock;
diff --git a/intern/guardedalloc/intern/mallocn_lockfree_impl.c b/intern/guardedalloc/intern/mallocn_lockfree_impl.c
index b5ee539ff4d..5a969186b19 100644
--- a/intern/guardedalloc/intern/mallocn_lockfree_impl.c
+++ b/intern/guardedalloc/intern/mallocn_lockfree_impl.c
@@ -233,7 +233,7 @@ void *MEM_lockfree_callocN(size_t len, const char *str)
print_error("Calloc returns null: len=" SIZET_FORMAT " in %s, total %u\n",
SIZET_ARG(len),
str,
- (unsigned int)mem_in_use);
+ (uint)mem_in_use);
return NULL;
}
@@ -278,7 +278,7 @@ void *MEM_lockfree_mallocN(size_t len, const char *str)
print_error("Malloc returns null: len=" SIZET_FORMAT " in %s, total %u\n",
SIZET_ARG(len),
str,
- (unsigned int)mem_in_use);
+ (uint)mem_in_use);
return NULL;
}
@@ -292,7 +292,7 @@ void *MEM_lockfree_malloc_arrayN(size_t len, size_t size, const char *str)
SIZET_ARG(len),
SIZET_ARG(size),
str,
- (unsigned int)mem_in_use);
+ (uint)mem_in_use);
abort();
return NULL;
}
@@ -349,7 +349,7 @@ void *MEM_lockfree_mallocN_aligned(size_t len, size_t alignment, const char *str
print_error("Malloc returns null: len=" SIZET_FORMAT " in %s, total %u\n",
SIZET_ARG(len),
str,
- (unsigned int)mem_in_use);
+ (uint)mem_in_use);
return NULL;
}
@@ -401,7 +401,7 @@ size_t MEM_lockfree_get_memory_in_use(void)
return mem_in_use;
}
-unsigned int MEM_lockfree_get_memory_blocks_in_use(void)
+uint MEM_lockfree_get_memory_blocks_in_use(void)
{
return totblock;
}
diff --git a/intern/guardedalloc/tests/guardedalloc_alignment_test.cc b/intern/guardedalloc/tests/guardedalloc_alignment_test.cc
index ceda01c2fba..b1a2143c8dc 100644
--- a/intern/guardedalloc/tests/guardedalloc_alignment_test.cc
+++ b/intern/guardedalloc/tests/guardedalloc_alignment_test.cc
@@ -7,7 +7,7 @@
#include "MEM_guardedalloc.h"
#include "guardedalloc_test_base.h"
-#define CHECK_ALIGNMENT(ptr, align) EXPECT_EQ((size_t)ptr % align, 0)
+#define CHECK_ALIGNMENT(ptr, align) EXPECT_EQ(size_t(ptr) % align, 0)
namespace {