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:
authorClément Foucault <foucault.clem@gmail.com>2019-05-07 18:52:57 +0300
committerClément Foucault <foucault.clem@gmail.com>2019-05-08 18:49:27 +0300
commit45caba37330e623ed1dd8a24aa6698e937325c2b (patch)
tree6a2ca72816fafa42849574e41af410be3d2d6891 /source/blender/blenlib/BLI_memblock.h
parentf273141556c5c7a26880d88fe164c1aec901ed53 (diff)
BLI_memblock: New memory allocator
This is really close to BLI_mempool but uses an array to keep track of the chunks of memory. There is no tagging necessary to clear the whole structure so reuse is fast. Naturally supports iteration but does not support freeing.
Diffstat (limited to 'source/blender/blenlib/BLI_memblock.h')
-rw-r--r--source/blender/blenlib/BLI_memblock.h55
1 files changed, 55 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_memblock.h b/source/blender/blenlib/BLI_memblock.h
new file mode 100644
index 00000000000..375cb22c415
--- /dev/null
+++ b/source/blender/blenlib/BLI_memblock.h
@@ -0,0 +1,55 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2008 Blender Foundation.
+ * All rights reserved.
+ */
+
+#ifndef __BLI_MEMBLOCK_H__
+#define __BLI_MEMBLOCK_H__
+
+/** \file
+ * \ingroup bli
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "BLI_compiler_attrs.h"
+
+struct BLI_memblock;
+
+typedef struct BLI_memblock BLI_memblock;
+
+BLI_memblock *BLI_memblock_create(uint elem_size) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT;
+void *BLI_memblock_alloc(BLI_memblock *mblk) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1);
+void BLI_memblock_clear(BLI_memblock *mblk) ATTR_NONNULL(1);
+void BLI_memblock_destroy(BLI_memblock *mblk) ATTR_NONNULL(1);
+
+typedef struct BLI_memblock_iter {
+ BLI_memblock *mblk;
+ uint current_index;
+ uint elem_per_chunk;
+} BLI_memblock_iter;
+
+void BLI_memblock_iternew(BLI_memblock *pool, BLI_memblock_iter *iter) ATTR_NONNULL();
+void *BLI_memblock_iterstep(BLI_memblock_iter *iter) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __BLI_MEMBLOCK_H__ */