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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2016-06-02 11:01:03 +0300
committerCampbell Barton <ideasman42@gmail.com>2016-06-02 11:05:11 +0300
commit7980c7c10f0270843e68bdad3a752aa2154d226a (patch)
tree6990b3e1a06deafe220149df6e451e511dea9db7 /source
parent0bd8d6d1949f29d283c6f00d4a316c4c9b2c8a5e (diff)
BLI_array_store: store max size in BArrayInfo
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenlib/intern/array_store.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/source/blender/blenlib/intern/array_store.c b/source/blender/blenlib/intern/array_store.c
index b559061d2e3..2e112576dd2 100644
--- a/source/blender/blenlib/intern/array_store.c
+++ b/source/blender/blenlib/intern/array_store.c
@@ -229,7 +229,9 @@ typedef struct BArrayInfo {
/* pre-calculated */
size_t chunk_byte_size;
+ /* min/max limits (inclusive) */
size_t chunk_byte_size_min;
+ size_t chunk_byte_size_max;
size_t accum_read_ahead_bytes;
#ifdef USE_HASH_TABLE_ACCUMULATE
@@ -455,7 +457,7 @@ static void bchunk_list_ensure_min_size_last(
if (MIN2(chunk_prev->data_len, chunk_curr->data_len) < info->chunk_byte_size_min) {
const size_t data_merge_len = chunk_prev->data_len + chunk_curr->data_len;
/* we could pass, but no need */
- if (data_merge_len <= (info->chunk_byte_size * BCHUNK_SIZE_MAX_MUL)) {
+ if (data_merge_len <= info->chunk_byte_size_max) {
/* we have enough space to merge */
/* remove last from linklist */
@@ -548,6 +550,8 @@ static void bchunk_list_append_data(
const ubyte *data, const size_t data_len)
{
BLI_assert(data_len != 0);
+ BLI_assert(data_len <= info->chunk_byte_size_max);
+
// printf("data_len: %d\n", data_len);
#ifdef USE_MERGE_CHUNKS
if (!BLI_listbase_is_empty(&chunk_list->chunk_refs)) {
@@ -1374,6 +1378,7 @@ BArrayStore *BLI_array_store_create(
bs->info.chunk_byte_size = chunk_count * stride;
#ifdef USE_MERGE_CHUNKS
bs->info.chunk_byte_size_min = MAX2(1u, chunk_count / BCHUNK_SIZE_MIN_DIV) * stride;
+ bs->info.chunk_byte_size_max = (chunk_count * BCHUNK_SIZE_MAX_MUL) * stride;
#endif
#ifdef USE_HASH_TABLE_ACCUMULATE