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 'source/blender/blenlib/intern/BLI_memarena.c')
-rw-r--r--source/blender/blenlib/intern/BLI_memarena.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/BLI_memarena.c b/source/blender/blenlib/intern/BLI_memarena.c
index 747c2f0c2b7..6b845bf842e 100644
--- a/source/blender/blenlib/intern/BLI_memarena.c
+++ b/source/blender/blenlib/intern/BLI_memarena.c
@@ -38,6 +38,10 @@
#include "BLI_linklist.h"
#include "BLI_strict_flags.h"
+#ifdef WITH_MEM_VALGRIND
+# include "valgrind/memcheck.h"
+#endif
+
struct MemArena {
unsigned char *curbuf;
int bufsize, cursize;
@@ -56,6 +60,10 @@ MemArena *BLI_memarena_new(const int bufsize, const char *name)
ma->align = 8;
ma->name = name;
+#ifdef WITH_MEM_VALGRIND
+ VALGRIND_CREATE_MEMPOOL(ma, 0, false);
+#endif
+
return ma;
}
@@ -122,6 +130,10 @@ void *BLI_memarena_alloc(MemArena *ma, int size)
ma->curbuf += size;
ma->cursize -= size;
+#ifdef WITH_MEM_VALGRIND
+ VALGRIND_MEMPOOL_ALLOC(ma, ptr, size);
+#endif
+
return ptr;
}
@@ -152,4 +164,10 @@ void BLI_memarena_clear(MemArena *ma)
memset(ma->curbuf, 0, (size_t)curbuf_used);
}
}
+
+#ifdef WITH_MEM_VALGRIND
+ VALGRIND_DESTROY_MEMPOOL(ma);
+ VALGRIND_CREATE_MEMPOOL(ma, 0, false);
+#endif
+
}