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:
authorCampbell Barton <ideasman42@gmail.com>2012-10-19 14:40:32 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-10-19 14:40:32 +0400
commite527ce552e9e3864c7a2f5bb688ffa1d4cd0d5f1 (patch)
treea340f534a7d62e6f9129bbfbbd31b297b7e214b5 /source/blender/blenlib/intern/BLI_heap.c
parentb7642348e44c10710c0d3f65ccfdafdd964829a2 (diff)
add option to initialize heap with a known number of elements, since this may be known in advance - it avoids re-allocing too much.
Diffstat (limited to 'source/blender/blenlib/intern/BLI_heap.c')
-rw-r--r--source/blender/blenlib/intern/BLI_heap.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/source/blender/blenlib/intern/BLI_heap.c b/source/blender/blenlib/intern/BLI_heap.c
index ee7d93ea1a9..5e0762a5d68 100644
--- a/source/blender/blenlib/intern/BLI_heap.c
+++ b/source/blender/blenlib/intern/BLI_heap.c
@@ -67,16 +67,22 @@ struct Heap {
/***/
-Heap *BLI_heap_new(void)
+/* use when the size of the heap is known in advance */
+Heap *BLI_heap_new_ex(unsigned int tot_reserve)
{
Heap *heap = (Heap *)MEM_callocN(sizeof(Heap), __func__);
- heap->bufsize = 1;
- heap->tree = (HeapNode **)MEM_mallocN(sizeof(HeapNode *), "BLIHeapTree");
+ heap->bufsize = tot_reserve;
+ heap->tree = (HeapNode **)MEM_mallocN(tot_reserve * sizeof(HeapNode *), "BLIHeapTree");
heap->arena = BLI_memarena_new(1 << 16, "heap arena");
return heap;
}
+Heap *BLI_heap_new(void)
+{
+ return BLI_heap_new_ex(1);
+}
+
void BLI_heap_free(Heap *heap, HeapFreeFP ptrfreefp)
{
int i;