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:
authorJacques Lucke <jacques@blender.org>2020-05-14 18:42:54 +0300
committerJacques Lucke <jacques@blender.org>2020-05-14 18:42:54 +0300
commit461fee5328fd4450126c495cb6823c33c0588672 (patch)
tree452d37776da3f64afbfed6a5cbae8c7973a4451f /source/blender/blenlib/intern/BLI_memarena.c
parentea84c12a2bfa125229750c35fdde3a37bc73e286 (diff)
BLI: deduplicate address sanitizer code
Reviewers: brecht, campbellbarton Differential Revision: https://developer.blender.org/D7731
Diffstat (limited to 'source/blender/blenlib/intern/BLI_memarena.c')
-rw-r--r--source/blender/blenlib/intern/BLI_memarena.c21
1 files changed, 5 insertions, 16 deletions
diff --git a/source/blender/blenlib/intern/BLI_memarena.c b/source/blender/blenlib/intern/BLI_memarena.c
index fd2367aa992..fc381c22315 100644
--- a/source/blender/blenlib/intern/BLI_memarena.c
+++ b/source/blender/blenlib/intern/BLI_memarena.c
@@ -34,6 +34,7 @@
#include "MEM_guardedalloc.h"
+#include "BLI_asan.h"
#include "BLI_memarena.h"
#include "BLI_strict_flags.h"
#include "BLI_utildefines.h"
@@ -46,18 +47,6 @@
# define VALGRIND_MEMPOOL_ALLOC(pool, addr, size) UNUSED_VARS(pool, addr, size)
#endif
-/* Clang defines this. */
-#ifndef __has_feature
-# define __has_feature(x) 0
-#endif
-#if defined(__SANITIZE_ADDRESS__) || __has_feature(address_sanitizer)
-# include "sanitizer/asan_interface.h"
-#else
-/* Ensure return value is used. */
-# define ASAN_POISON_MEMORY_REGION(addr, size) (void)(0 && ((size) != 0 && (addr) != NULL))
-# define ASAN_UNPOISON_MEMORY_REGION(addr, size) (void)(0 && ((size) != 0 && (addr) != NULL))
-#endif
-
struct MemBuf {
struct MemBuf *next;
uchar data[0];
@@ -80,7 +69,7 @@ static void memarena_buf_free_all(struct MemBuf *mb)
struct MemBuf *mb_next = mb->next;
/* Unpoison memory because MEM_freeN might overwrite it. */
- ASAN_UNPOISON_MEMORY_REGION(mb, (uint)MEM_allocN_len(mb));
+ BLI_asan_unpoison(mb, (uint)MEM_allocN_len(mb));
MEM_freeN(mb);
mb = mb_next;
@@ -160,7 +149,7 @@ void *BLI_memarena_alloc(MemArena *ma, size_t size)
mb->next = ma->bufs;
ma->bufs = mb;
- ASAN_POISON_MEMORY_REGION(ma->curbuf, ma->cursize);
+ BLI_asan_poison(ma->curbuf, ma->cursize);
memarena_curbuf_align(ma);
}
@@ -171,7 +160,7 @@ void *BLI_memarena_alloc(MemArena *ma, size_t size)
VALGRIND_MEMPOOL_ALLOC(ma, ptr, size);
- ASAN_UNPOISON_MEMORY_REGION(ptr, size);
+ BLI_asan_unpoison(ptr, size);
return ptr;
}
@@ -215,7 +204,7 @@ void BLI_memarena_clear(MemArena *ma)
if (ma->use_calloc) {
memset(ma->curbuf, 0, curbuf_used);
}
- ASAN_POISON_MEMORY_REGION(ma->curbuf, ma->cursize);
+ BLI_asan_poison(ma->curbuf, ma->cursize);
}
VALGRIND_DESTROY_MEMPOOL(ma);