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:
authorDalai Felinto <dalai@blender.org>2020-04-03 20:15:01 +0300
committerDalai Felinto <dalai@blender.org>2020-04-03 20:27:46 +0300
commitd138cbfb47e379edc1ee915a8c6ff65b01f000d6 (patch)
treef4773ecce897c32eaf75295dd5f6a8e730d471ed /source/blender/blenlib/intern/array_store.c
parentb0c1184875d39abac4a65a5d20e263ea6d841009 (diff)
Code Quality: Replace for loops with LISTBASE_FOREACH
Note this only changes cases where the variable was declared inside the for loop. To handle it outside as well is a different challenge. Differential Revision: https://developer.blender.org/D7320
Diffstat (limited to 'source/blender/blenlib/intern/array_store.c')
-rw-r--r--source/blender/blenlib/intern/array_store.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/source/blender/blenlib/intern/array_store.c b/source/blender/blenlib/intern/array_store.c
index c87dbee0f0e..85fbe7ece0f 100644
--- a/source/blender/blenlib/intern/array_store.c
+++ b/source/blender/blenlib/intern/array_store.c
@@ -406,7 +406,7 @@ static void bchunk_list_decref(BArrayMemory *bs_mem, BChunkList *chunk_list)
static size_t bchunk_list_data_check(const BChunkList *chunk_list, const uchar *data)
{
size_t offset = 0;
- for (BChunkRef *cref = chunk_list->chunk_refs.first; cref; cref = cref->next) {
+ LISTBASE_FOREACH (BChunkRef *, cref, &chunk_list->chunk_refs) {
if (memcmp(&data[offset], cref->link->data, cref->link->data_len) != 0) {
return false;
}
@@ -1511,7 +1511,7 @@ void BLI_array_store_clear(BArrayStore *bs)
size_t BLI_array_store_calc_size_expanded_get(const BArrayStore *bs)
{
size_t size_accum = 0;
- for (const BArrayState *state = bs->states.first; state; state = state->next) {
+ LISTBASE_FOREACH (const BArrayState *, state, &bs->states) {
size_accum += state->chunk_list->total_size;
}
return size_accum;
@@ -1632,14 +1632,14 @@ void BLI_array_store_state_data_get(BArrayState *state, void *data)
{
#ifdef USE_PARANOID_CHECKS
size_t data_test_len = 0;
- for (BChunkRef *cref = state->chunk_list->chunk_refs.first; cref; cref = cref->next) {
+ LISTBASE_FOREACH (BChunkRef *, cref, &state->chunk_list->chunk_refs) {
data_test_len += cref->link->data_len;
}
BLI_assert(data_test_len == state->chunk_list->total_size);
#endif
uchar *data_step = (uchar *)data;
- for (BChunkRef *cref = state->chunk_list->chunk_refs.first; cref; cref = cref->next) {
+ LISTBASE_FOREACH (BChunkRef *, cref, &state->chunk_list->chunk_refs) {
BLI_assert(cref->link->users > 0);
memcpy(data_step, cref->link->data, cref->link->data_len);
data_step += cref->link->data_len;
@@ -1666,7 +1666,7 @@ void *BLI_array_store_state_data_get_alloc(BArrayState *state, size_t *r_data_le
static size_t bchunk_list_size(const BChunkList *chunk_list)
{
size_t total_size = 0;
- for (BChunkRef *cref = chunk_list->chunk_refs.first; cref; cref = cref->next) {
+ LISTBASE_FOREACH (BChunkRef *, cref, &chunk_list->chunk_refs) {
total_size += cref->link->data_len;
}
return total_size;
@@ -1679,7 +1679,7 @@ bool BLI_array_store_is_valid(BArrayStore *bs)
/* Check Length
* ------------ */
- for (BArrayState *state = bs->states.first; state; state = state->next) {
+ LISTBASE_FOREACH (BArrayState *, state, &bs->states) {
BChunkList *chunk_list = state->chunk_list;
if (!(bchunk_list_size(chunk_list) == chunk_list->total_size)) {
return false;
@@ -1692,7 +1692,7 @@ bool BLI_array_store_is_valid(BArrayStore *bs)
#ifdef USE_MERGE_CHUNKS
/* ensure we merge all chunks that could be merged */
if (chunk_list->total_size > bs->info.chunk_byte_size_min) {
- for (BChunkRef *cref = chunk_list->chunk_refs.first; cref; cref = cref->next) {
+ LISTBASE_FOREACH (BChunkRef *, cref, &chunk_list->chunk_refs) {
if (cref->link->data_len < bs->info.chunk_byte_size_min) {
return false;
}
@@ -1734,7 +1734,7 @@ bool BLI_array_store_is_valid(BArrayStore *bs)
GHash *chunk_map = BLI_ghash_ptr_new(__func__);
int totrefs = 0;
- for (BArrayState *state = bs->states.first; state; state = state->next) {
+ LISTBASE_FOREACH (BArrayState *, state, &bs->states) {
GHASH_PTR_ADD_USER(chunk_list_map, state->chunk_list);
}
GHASH_ITER (gh_iter, chunk_list_map) {
@@ -1753,7 +1753,7 @@ bool BLI_array_store_is_valid(BArrayStore *bs)
/* count chunk's */
GHASH_ITER (gh_iter, chunk_list_map) {
const struct BChunkList *chunk_list = BLI_ghashIterator_getKey(&gh_iter);
- for (const BChunkRef *cref = chunk_list->chunk_refs.first; cref; cref = cref->next) {
+ LISTBASE_FOREACH (const BChunkRef *, cref, &chunk_list->chunk_refs) {
GHASH_PTR_ADD_USER(chunk_map, cref->link);
totrefs += 1;
}