diff options
author | Sebastian Parborg <darkdefende@gmail.com> | 2021-08-20 17:30:34 +0300 |
---|---|---|
committer | Sebastian Parborg <darkdefende@gmail.com> | 2021-08-25 18:30:39 +0300 |
commit | f49d438ced7c5874dbf43976d9901a462176f541 (patch) | |
tree | fae7b745eaf1e793b53119f3ec27c34621727c58 /source/blender/sequencer/intern/utils.c | |
parent | 796035ad930383c26302ab6a57e8e6c90394603b (diff) |
Cleanup and remove SEQ_ALL_BEGIN macro
We now use a for_each function with callback to iterate through all sequences in the scene.
This has the benefit that we now only loop over the sequences in the scene once.
Before we would loop over them twice and allocate memory to store temporary data.
The allocation of temporary data lead to unintentional memory leaks if the code used returns to exit out of the iteration loop.
The new for_each callback method doesn't allocate any temporary data and only iterates though all sequences once.
Reviewed By: Richard Antalik, Bastien Montagne
Differential Revision: http://developer.blender.org/D12278
Diffstat (limited to 'source/blender/sequencer/intern/utils.c')
-rw-r--r-- | source/blender/sequencer/intern/utils.c | 34 |
1 files changed, 3 insertions, 31 deletions
diff --git a/source/blender/sequencer/intern/utils.c b/source/blender/sequencer/intern/utils.c index f946affe1d8..e4eecaf552c 100644 --- a/source/blender/sequencer/intern/utils.c +++ b/source/blender/sequencer/intern/utils.c @@ -133,12 +133,12 @@ static void seqbase_unique_name(ListBase *seqbasep, SeqUniqueInfo *sui) } } -static int seqbase_unique_name_recursive_fn(Sequence *seq, void *arg_pt) +static bool seqbase_unique_name_recursive_fn(Sequence *seq, void *arg_pt) { if (seq->seqbase.first) { seqbase_unique_name(&seq->seqbase, (SeqUniqueInfo *)arg_pt); } - return 1; + return true; } void SEQ_sequence_base_unique_name_recursive(struct Scene *scene, @@ -167,7 +167,7 @@ void SEQ_sequence_base_unique_name_recursive(struct Scene *scene, while (sui.match) { sui.match = 0; seqbase_unique_name(seqbasep, &sui); - SEQ_seqbase_recursive_apply(seqbasep, seqbase_unique_name_recursive_fn, &sui); + SEQ_for_each_callback(seqbasep, seqbase_unique_name_recursive_fn, &sui); } SEQ_edit_sequence_name_set(scene, seq, sui.name_dest); @@ -573,34 +573,6 @@ void SEQ_set_scale_to_fit(const Sequence *seq, } } -int SEQ_seqbase_recursive_apply(ListBase *seqbase, - int (*apply_fn)(Sequence *seq, void *), - void *arg) -{ - Sequence *iseq; - for (iseq = seqbase->first; iseq; iseq = iseq->next) { - if (SEQ_recursive_apply(iseq, apply_fn, arg) == -1) { - return -1; /* bail out */ - } - } - return 1; -} - -int SEQ_recursive_apply(Sequence *seq, int (*apply_fn)(Sequence *, void *), void *arg) -{ - int ret = apply_fn(seq, arg); - - if (ret == -1) { - return -1; /* bail out */ - } - - if (ret && seq->seqbase.first) { - ret = SEQ_seqbase_recursive_apply(&seq->seqbase, apply_fn, arg); - } - - return ret; -} - /** * Ensure, that provided Sequence has unique name. If animation data exists for this Sequence, it * will be duplicated and mapped onto new name |