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>2014-02-07 23:07:10 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-02-07 23:24:05 +0400
commitb3afbcab8ff2330c1473647be330a3ffe9b11885 (patch)
treee86b9c7d9676e63b8da92da79889dee13b8be186 /source
parent1c24d954f4ac63f22b703756b6664a4ad1b363d4 (diff)
ListBase API: add utility api funcs for clearing and checking empty
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenfont/intern/blf_font.c3
-rw-r--r--source/blender/blenkernel/intern/action.c9
-rw-r--r--source/blender/blenkernel/intern/anim_sys.c10
-rw-r--r--source/blender/blenkernel/intern/armature.c2
-rw-r--r--source/blender/blenkernel/intern/blender.c2
-rw-r--r--source/blender/blenkernel/intern/bpath.c2
-rw-r--r--source/blender/blenkernel/intern/constraint.c2
-rw-r--r--source/blender/blenkernel/intern/context.c3
-rw-r--r--source/blender/blenkernel/intern/curve.c8
-rw-r--r--source/blender/blenkernel/intern/deform.c2
-rw-r--r--source/blender/blenkernel/intern/depsgraph.c10
-rw-r--r--source/blender/blenkernel/intern/displist.c7
-rw-r--r--source/blender/blenkernel/intern/fcurve.c8
-rw-r--r--source/blender/blenkernel/intern/fmodifier.c4
-rw-r--r--source/blender/blenkernel/intern/freestyle.c8
-rw-r--r--source/blender/blenkernel/intern/gpencil.c10
-rw-r--r--source/blender/blenkernel/intern/group.c4
-rw-r--r--source/blender/blenkernel/intern/implicit.c2
-rw-r--r--source/blender/blenkernel/intern/ipo.c2
-rw-r--r--source/blender/blenkernel/intern/key.c2
-rw-r--r--source/blender/blenkernel/intern/linestyle.c11
-rw-r--r--source/blender/blenkernel/intern/mask.c10
-rw-r--r--source/blender/blenkernel/intern/material.c6
-rw-r--r--source/blender/blenkernel/intern/mball.c8
-rw-r--r--source/blender/blenkernel/intern/nla.c8
-rw-r--r--source/blender/blenkernel/intern/node.c8
-rw-r--r--source/blender/blenkernel/intern/object.c16
-rw-r--r--source/blender/blenkernel/intern/object_deform.c3
-rw-r--r--source/blender/blenkernel/intern/object_dupli.c4
-rw-r--r--source/blender/blenkernel/intern/particle.c6
-rw-r--r--source/blender/blenkernel/intern/particle_system.c4
-rw-r--r--source/blender/blenkernel/intern/pointcache.c7
-rw-r--r--source/blender/blenkernel/intern/report.c2
-rw-r--r--source/blender/blenkernel/intern/scene.c2
-rw-r--r--source/blender/blenkernel/intern/screen.c16
-rw-r--r--source/blender/blenkernel/intern/seqcache.c2
-rw-r--r--source/blender/blenkernel/intern/seqmodifier.c2
-rw-r--r--source/blender/blenkernel/intern/sequencer.c12
-rw-r--r--source/blender/blenkernel/intern/sketch.c3
-rw-r--r--source/blender/blenkernel/intern/smoke.c2
-rw-r--r--source/blender/blenkernel/intern/text.c8
-rw-r--r--source/blender/blenkernel/intern/tracking.c8
-rw-r--r--source/blender/blenlib/BLI_listbase.h7
-rw-r--r--source/blender/blenlib/intern/BLI_args.c2
-rw-r--r--source/blender/blenlib/intern/BLI_mempool.c6
-rw-r--r--source/blender/blenlib/intern/scanfill.c18
-rw-r--r--source/blender/blenlib/intern/task.c2
-rw-r--r--source/blender/blenlib/intern/threads.c4
-rw-r--r--source/blender/blenloader/intern/readblenentry.c2
-rw-r--r--source/blender/blenloader/intern/readfile.c79
-rw-r--r--source/blender/blenloader/intern/versioning_250.c2
-rw-r--r--source/blender/blenloader/intern/versioning_260.c4
-rw-r--r--source/blender/blenloader/intern/versioning_legacy.c3
-rw-r--r--source/blender/bmesh/intern/bmesh_edgeloop.c2
-rw-r--r--source/blender/bmesh/intern/bmesh_marking.c1
-rw-r--r--source/blender/bmesh/intern/bmesh_operators.c2
-rw-r--r--source/blender/bmesh/intern/bmesh_walkers.c2
-rw-r--r--source/blender/bmesh/operators/bmo_connect_pair.c5
-rw-r--r--source/blender/collada/ArmatureExporter.cpp2
-rw-r--r--source/blender/collada/SceneExporter.cpp2
-rw-r--r--source/blender/editors/animation/anim_channels_edit.c14
-rw-r--r--source/blender/editors/animation/anim_filter.c32
-rw-r--r--source/blender/editors/animation/keyframes_general.c10
-rw-r--r--source/blender/editors/animation/keyframing.c2
-rw-r--r--source/blender/editors/animation/keyingsets.c2
-rw-r--r--source/blender/editors/armature/armature_edit.c4
-rw-r--r--source/blender/editors/armature/armature_utils.c5
-rw-r--r--source/blender/editors/armature/editarmature_retarget.c4
-rw-r--r--source/blender/editors/armature/editarmature_sketch.c9
-rw-r--r--source/blender/editors/armature/pose_group.c2
-rw-r--r--source/blender/editors/armature/pose_lib.c2
-rw-r--r--source/blender/editors/armature/pose_utils.c2
-rw-r--r--source/blender/editors/curve/editcurve.c10
-rw-r--r--source/blender/editors/gpencil/editaction_gpencil.c6
-rw-r--r--source/blender/editors/gpencil/gpencil_edit.c2
-rw-r--r--source/blender/editors/gpencil/gpencil_undo.c4
-rw-r--r--source/blender/editors/interface/interface.c4
-rw-r--r--source/blender/editors/interface/interface_handlers.c7
-rw-r--r--source/blender/editors/interface/interface_icons.c2
-rw-r--r--source/blender/editors/interface/interface_layout.c4
-rw-r--r--source/blender/editors/mask/mask_ops.c2
-rw-r--r--source/blender/editors/mesh/editmesh_knife.c2
-rw-r--r--source/blender/editors/mesh/editmesh_select.c2
-rw-r--r--source/blender/editors/metaball/mball_edit.c3
-rw-r--r--source/blender/editors/object/object_add.c2
-rw-r--r--source/blender/editors/object/object_edit.c3
-rw-r--r--source/blender/editors/object/object_lattice.c2
-rw-r--r--source/blender/editors/object/object_modifier.c2
-rw-r--r--source/blender/editors/object/object_select.c2
-rw-r--r--source/blender/editors/object/object_vgroup.c8
-rw-r--r--source/blender/editors/physics/particle_edit.c6
-rw-r--r--source/blender/editors/screen/area.c6
-rw-r--r--source/blender/editors/screen/screen_edit.c10
-rw-r--r--source/blender/editors/sculpt_paint/paint_undo.c2
-rw-r--r--source/blender/editors/sculpt_paint/paint_utils.c3
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.c2
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex_proj.c3
-rw-r--r--source/blender/editors/space_buttons/buttons_texture.c2
-rw-r--r--source/blender/editors/space_console/space_console.c6
-rw-r--r--source/blender/editors/space_graph/graph_draw.c2
-rw-r--r--source/blender/editors/space_graph/graph_edit.c2
-rw-r--r--source/blender/editors/space_graph/graph_select.c4
-rw-r--r--source/blender/editors/space_image/image_buttons.c2
-rw-r--r--source/blender/editors/space_image/image_ops.c2
-rw-r--r--source/blender/editors/space_nla/nla_channels.c2
-rw-r--r--source/blender/editors/space_nla/nla_edit.c6
-rw-r--r--source/blender/editors/space_node/node_add.c5
-rw-r--r--source/blender/editors/space_node/node_edit.c2
-rw-r--r--source/blender/editors/space_node/node_relationships.c4
-rw-r--r--source/blender/editors/space_node/node_templates.c2
-rw-r--r--source/blender/editors/space_node/space_node.c4
-rw-r--r--source/blender/editors/space_outliner/outliner_draw.c2
-rw-r--r--source/blender/editors/space_outliner/outliner_tree.c4
-rw-r--r--source/blender/editors/space_outliner/space_outliner.c2
-rw-r--r--source/blender/editors/space_sequencer/sequencer_edit.c5
-rw-r--r--source/blender/editors/space_time/space_time.c2
-rw-r--r--source/blender/editors/space_view3d/drawobject.c6
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_ruler.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c2
-rw-r--r--source/blender/editors/transform/transform_conversions.c8
-rw-r--r--source/blender/editors/transform/transform_snap.c4
-rw-r--r--source/blender/ikplugin/intern/itasc_plugin.cpp6
-rw-r--r--source/blender/imbuf/intern/cache.c2
-rw-r--r--source/blender/imbuf/intern/colormanagement.c4
-rw-r--r--source/blender/imbuf/intern/openexr/openexr_api.cpp2
-rw-r--r--source/blender/makesrna/intern/rna_animation.c2
-rw-r--r--source/blender/makesrna/intern/rna_space.c2
-rw-r--r--source/blender/modifiers/intern/MOD_mask.c2
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgedit.c3
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgmix.c3
-rw-r--r--source/blender/modifiers/intern/MOD_weightvgproximity.c3
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_image.c2
-rw-r--r--source/blender/nodes/intern/node_common.c4
-rw-r--r--source/blender/render/intern/source/envmap.c10
-rw-r--r--source/blender/render/intern/source/multires_bake.c2
-rw-r--r--source/blender/render/intern/source/render_result.c2
-rw-r--r--source/blender/render/intern/source/rendercore.c2
-rw-r--r--source/blender/windowmanager/intern/wm.c12
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c4
-rw-r--r--source/blender/windowmanager/intern/wm_files.c16
-rw-r--r--source/blender/windowmanager/intern/wm_keymap.c2
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c2
-rw-r--r--source/creator/creator.c2
-rw-r--r--source/gameengine/Converter/BL_ArmatureObject.cpp6
-rw-r--r--source/gameengine/VideoTexture/VideoFFmpeg.cpp10
146 files changed, 389 insertions, 380 deletions
diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c
index 846c9cca55c..ac035026814 100644
--- a/source/blender/blenfont/intern/blf_font.c
+++ b/source/blender/blenfont/intern/blf_font.c
@@ -701,8 +701,7 @@ static void blf_font_fill(FontBLF *font)
font->flags = 0;
font->dpi = 0;
font->size = 0;
- font->cache.first = NULL;
- font->cache.last = NULL;
+ BLI_listbase_clear(&font->cache);
font->glyph_cache = NULL;
font->blur = 0;
font->max_tex_size = -1;
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index 8967df14b24..3a32cad0873 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -193,7 +193,7 @@ bAction *BKE_action_copy(bAction *src)
BLI_duplicatelist(&dst->markers, &src->markers);
/* copy F-Curves, fixing up the links as we go */
- dst->curves.first = dst->curves.last = NULL;
+ BLI_listbase_clear(&dst->curves);
for (sfcu = src->curves.first; sfcu; sfcu = sfcu->next) {
/* duplicate F-Curve */
@@ -319,7 +319,7 @@ void action_groups_add_channel(bAction *act, bActionGroup *agrp, FCurve *fcurve)
return;
/* if no channels anywhere, just add to two lists at the same time */
- if (act->curves.first == NULL) {
+ if (BLI_listbase_is_empty(&act->curves)) {
fcurve->next = fcurve->prev = NULL;
agrp->channels.first = agrp->channels.last = fcurve;
@@ -390,8 +390,7 @@ void action_groups_remove_channel(bAction *act, FCurve *fcu)
if (agrp->channels.first == agrp->channels.last) {
if (agrp->channels.first == fcu) {
- agrp->channels.first = NULL;
- agrp->channels.last = NULL;
+ BLI_listbase_clear(&agrp->channels);
}
}
else if (agrp->channels.first == fcu) {
@@ -998,7 +997,7 @@ void BKE_pose_remove_group(Object *ob)
/* now, remove it from the pose */
BLI_freelinkN(&pose->agroups, grp);
pose->active_group--;
- if (pose->active_group < 0 || pose->agroups.first == NULL) {
+ if (pose->active_group < 0 || BLI_listbase_is_empty(&pose->agroups)) {
pose->active_group = 0;
}
}
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index a46b308f76b..5c50b9d6bec 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -273,7 +273,7 @@ AnimData *BKE_copy_animdata(AnimData *adt, const bool do_action)
copy_fcurves(&dadt->drivers, &adt->drivers);
/* don't copy overrides */
- dadt->overrides.first = dadt->overrides.last = NULL;
+ BLI_listbase_clear(&dadt->overrides);
/* return */
return dadt;
@@ -465,7 +465,7 @@ void action_move_fcurves_by_basepath(bAction *srcAct, bAction *dstAct, const cha
/* if group is empty and tagged, then we can remove as this operation
* moved out all the channels that were formerly here
*/
- if (agrp->channels.first == NULL)
+ if (BLI_listbase_is_empty(&agrp->channels))
BLI_freelinkN(&srcAct->groups, agrp);
else
agrp->flag &= ~AGRP_TEMP;
@@ -1900,7 +1900,7 @@ static void nlaevalchan_buffers_accumulate(ListBase *channels, ListBase *tmp_buf
NlaEvalChannel *nec, *necn, *necd;
/* optimize - abort if no channels */
- if (tmp_buffer->first == NULL)
+ if (BLI_listbase_is_empty(tmp_buffer))
return;
/* accumulate results in tmp_channels buffer to the accumulation buffer */
@@ -2308,7 +2308,7 @@ static void animsys_evaluate_nla(ListBase *echannels, PointerRNA *ptr, AnimData
}
/* only continue if there are strips to evaluate */
- if (estrips.first == NULL)
+ if (BLI_listbase_is_empty(&estrips))
return;
@@ -2524,7 +2524,7 @@ void BKE_animsys_evaluate_all_animation(Main *main, Scene *scene, float ctime)
* however, if there are some curves, we will need to make sure that their 'ctime' property gets
* set correctly, so this optimization must be skipped in that case...
*/
- if ((main->action.first == NULL) && (main->curve.first == NULL)) {
+ if (BLI_listbase_is_empty(&main->action) && BLI_listbase_is_empty(&main->curve)) {
if (G.debug & G_DEBUG)
printf("\tNo Actions, so no animation needs to be evaluated...\n");
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index 699e71393c8..caec93a6627 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -2537,7 +2537,7 @@ static int minmax_armature(Object *ob, float r_min[3], float r_max[3])
minmax_v3v3_v3(r_min, r_max, pchan->pose_tail);
}
- return (ob->pose->chanbase.first != NULL);
+ return (BLI_listbase_is_empty(&ob->pose->chanbase) == false);
}
static void boundbox_armature(Object *ob, float loc[3], float size[3])
diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c
index 2b87a7684d2..ed48bf5f3a4 100644
--- a/source/blender/blenkernel/intern/blender.c
+++ b/source/blender/blenkernel/intern/blender.c
@@ -204,7 +204,7 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath
char mode;
/* 'u' = undo save, 'n' = no UI load */
- if (bfd->main->screen.first == NULL) mode = 'u';
+ if (BLI_listbase_is_empty(&bfd->main->screen)) mode = 'u';
else if (G.fileflags & G_FILE_NO_UI) mode = 'n';
else mode = 0;
diff --git a/source/blender/blenkernel/intern/bpath.c b/source/blender/blenkernel/intern/bpath.c
index b7a6cf4153a..00fff61c6a2 100644
--- a/source/blender/blenkernel/intern/bpath.c
+++ b/source/blender/blenkernel/intern/bpath.c
@@ -755,7 +755,7 @@ void BKE_bpath_list_restore(Main *bmain, const int flag, void *ls_handle)
void BKE_bpath_list_free(void *ls_handle)
{
ListBase *ls = ls_handle;
- BLI_assert(ls->first == NULL); /* assumes we were used */
+ BLI_assert(BLI_listbase_is_empty(ls)); /* assumes we were used */
BLI_freelistN(ls);
MEM_freeN(ls);
}
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index 2eca9f30bfb..c14e8dd5e16 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -4490,7 +4490,7 @@ void BKE_copy_constraints(ListBase *dst, const ListBase *src, int do_extern)
{
bConstraint *con, *srccon;
- dst->first = dst->last = NULL;
+ BLI_listbase_clear(dst);
BLI_duplicatelist(dst, src);
for (con = dst->first, srccon = src->first; con && srccon; srccon = srccon->next, con = con->next) {
diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c
index 2eb763831e4..a63807f4bcb 100644
--- a/source/blender/blenkernel/intern/context.c
+++ b/source/blender/blenkernel/intern/context.c
@@ -366,8 +366,7 @@ static int ctx_data_collection_get(const bContext *C, const char *member, ListBa
return 1;
}
- list->first = NULL;
- list->last = NULL;
+ BLI_listbase_clear(list);
return 0;
}
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index c5979686afb..8567a57d153 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -206,7 +206,7 @@ Curve *BKE_curve_copy(Curve *cu)
int a;
cun = BKE_libblock_copy(&cu->id);
- cun->nurb.first = cun->nurb.last = NULL;
+ BLI_listbase_clear(&cun->nurb);
BKE_nurbList_duplicate(&(cun->nurb), &(cu->nurb));
cun->mat = MEM_dupallocN(cu->mat);
@@ -534,7 +534,7 @@ void BKE_nurbList_free(ListBase *lb)
BKE_nurb_free(nu);
nu = next;
}
- lb->first = lb->last = NULL;
+ BLI_listbase_clear(lb);
}
Nurb *BKE_nurb_duplicate(Nurb *nu)
@@ -1628,7 +1628,7 @@ void BKE_curve_bevel_make(Scene *scene, Object *ob, ListBase *disp, int forRende
int nr, a;
cu = ob->data;
- disp->first = disp->last = NULL;
+ BLI_listbase_clear(disp);
/* if a font object is being edited, then do nothing */
// XXX if ( ob == obedit && ob->type == OB_FONT ) return;
@@ -4039,7 +4039,7 @@ bool BKE_curve_minmax(Curve *cu, bool use_radius, float min[3], float max[3])
for (nu = nurb_lb->first; nu; nu = nu->next)
BKE_nurb_minmax(nu, use_radius, min, max);
- return (nurb_lb->first != NULL);
+ return (BLI_listbase_is_empty(nurb_lb) == false);
}
bool BKE_curve_center_median(Curve *cu, float cent[3])
diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c
index 6ff27e50bf8..82b6dded29c 100644
--- a/source/blender/blenkernel/intern/deform.c
+++ b/source/blender/blenkernel/intern/deform.c
@@ -71,7 +71,7 @@ void defgroup_copy_list(ListBase *outbase, ListBase *inbase)
{
bDeformGroup *defgroup, *defgroupn;
- outbase->first = outbase->last = NULL;
+ BLI_listbase_clear(outbase);
for (defgroup = inbase->first; defgroup; defgroup = defgroup->next) {
defgroupn = defgroup_duplicate(defgroup);
diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c
index 5f4bfc8ad23..af84055fb50 100644
--- a/source/blender/blenkernel/intern/depsgraph.c
+++ b/source/blender/blenkernel/intern/depsgraph.c
@@ -1379,7 +1379,7 @@ static void dag_scene_build(Main *bmain, Scene *sce)
ListBase tempbase;
Base *base;
- tempbase.first = tempbase.last = NULL;
+ BLI_listbase_clear(&tempbase);
build_dag(bmain, sce, DAG_RL_ALL_BUT_DATA);
@@ -1941,7 +1941,7 @@ static void dag_object_time_update_flags(Main *bmain, Scene *scene, Object *ob)
break;
case OB_FONT:
cu = ob->data;
- if (cu->nurb.first == NULL && cu->str && cu->vfont)
+ if (BLI_listbase_is_empty(&cu->nurb) && cu->str && cu->vfont)
ob->recalc |= OB_RECALC_DATA;
break;
case OB_LATTICE:
@@ -2078,7 +2078,7 @@ static void dag_current_scene_layers(Main *bmain, ListBase *lb)
wmWindowManager *wm;
wmWindow *win;
- lb->first = lb->last = NULL;
+ BLI_listbase_clear(lb);
/* if we have a windowmanager, look into windows */
if ((wm = bmain->wm.first)) {
@@ -2411,7 +2411,7 @@ void DAG_ids_flush_tagged(Main *bmain)
/* get list of visible scenes and layers */
dag_current_scene_layers(bmain, &listbase);
- if (listbase.first == NULL)
+ if (BLI_listbase_is_empty(&listbase))
return;
/* loop over all ID types */
@@ -2774,7 +2774,7 @@ void DAG_pose_sort(Object *ob)
dag_check_cycle(dag);
/* now we try to sort... */
- tempbase.first = tempbase.last = NULL;
+ BLI_listbase_clear(&tempbase);
nqueue = queue_create(DAGQUEUEALLOC);
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c
index ee2c42d33cd..517c8329567 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -462,7 +462,7 @@ void BKE_displist_fill(ListBase *dispbase, ListBase *to, const float normal_proj
if (dispbase == NULL)
return;
- if (dispbase->first == NULL)
+ if (BLI_listbase_is_empty(dispbase))
return;
sf_arena = BLI_memarena_new(BLI_SCANFILL_ARENA_SIZE, __func__);
@@ -588,7 +588,8 @@ static void bevels_to_filledpoly(Curve *cu, ListBase *dispbase)
float *fp, *fp1;
int a, dpoly;
- front.first = front.last = back.first = back.last = NULL;
+ BLI_listbase_clear(&front);
+ BLI_listbase_clear(&back);
dl = dispbase->first;
while (dl) {
@@ -1409,7 +1410,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
if (bl->nr) { /* blank bevel lists can happen */
/* exception handling; curve without bevel or extrude, with width correction */
- if (dlbev.first == NULL) {
+ if (BLI_listbase_is_empty(&dlbev)) {
dl = MEM_callocN(sizeof(DispList), "makeDispListbev");
dl->verts = MEM_callocN(3 * sizeof(float) * bl->nr, "dlverts");
BLI_addtail(dispbase, dl);
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index c93181bd903..bcdb066a965 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -112,7 +112,7 @@ void free_fcurves(ListBase *list)
}
/* clear pointers just in case */
- list->first = list->last = NULL;
+ BLI_listbase_clear(list);
}
/* ---------------------- Copy --------------------------- */
@@ -159,7 +159,7 @@ void copy_fcurves(ListBase *dst, ListBase *src)
return;
/* clear destination list first */
- dst->first = dst->last = NULL;
+ BLI_listbase_clear(dst);
/* copy one-by-one */
for (sfcu = src->first; sfcu; sfcu = sfcu->next) {
@@ -1588,7 +1588,7 @@ ChannelDriver *fcurve_copy_driver(ChannelDriver *driver)
ndriver->expr_comp = NULL;
/* copy variables */
- ndriver->variables.first = ndriver->variables.last = NULL;
+ BLI_listbase_clear(&ndriver->variables);
BLI_duplicatelist(&ndriver->variables, &driver->variables);
for (dvar = ndriver->variables.first; dvar; dvar = dvar->next) {
@@ -1648,7 +1648,7 @@ static float evaluate_driver(ChannelDriver *driver, const float evaltime)
case DRIVER_TYPE_SUM: /* sum values of driver targets */
{
/* check how many variables there are first (i.e. just one?) */
- if (driver->variables.first == driver->variables.last) {
+ if (BLI_listbase_is_single(&driver->variables)) {
/* just one target, so just use that */
dvar = driver->variables.first;
driver->curval = driver_get_variable_value(driver, dvar);
diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c
index 325a26d7a16..6c98808f087 100644
--- a/source/blender/blenkernel/intern/fmodifier.c
+++ b/source/blender/blenkernel/intern/fmodifier.c
@@ -1102,7 +1102,7 @@ FModifier *add_fmodifier(ListBase *modifiers, int type)
BLI_addtail(modifiers, fcm);
/* tag modifier as "active" if no other modifiers exist in the stack yet */
- if (modifiers->first == modifiers->last)
+ if (BLI_listbase_is_single(modifiers))
fcm->flag |= FMODIFIER_FLAG_ACTIVE;
/* add modifier's data */
@@ -1149,7 +1149,7 @@ void copy_fmodifiers(ListBase *dst, ListBase *src)
if (ELEM(NULL, dst, src))
return;
- dst->first = dst->last = NULL;
+ BLI_listbase_clear(dst);
BLI_duplicatelist(dst, src);
for (fcm = dst->first, srcfcm = src->first; fcm && srcfcm; srcfcm = srcfcm->next, fcm = fcm->next) {
diff --git a/source/blender/blenkernel/intern/freestyle.c b/source/blender/blenkernel/intern/freestyle.c
index 3e0668ba05c..f5a9ba4e241 100644
--- a/source/blender/blenkernel/intern/freestyle.c
+++ b/source/blender/blenkernel/intern/freestyle.c
@@ -50,13 +50,13 @@ void BKE_freestyle_config_init(FreestyleConfig *config)
{
config->mode = FREESTYLE_CONTROL_EDITOR_MODE;
- config->modules.first = config->modules.last = NULL;
+ BLI_listbase_clear(&config->modules);
config->flags = 0;
config->sphere_radius = 0.1f;
config->dkr_epsilon = 0.0f;
config->crease_angle = DEG2RADF(134.43f);
- config->linesets.first = config->linesets.last = NULL;
+ BLI_listbase_clear(&config->linesets);
}
void BKE_freestyle_config_free(FreestyleConfig *config)
@@ -88,14 +88,14 @@ void BKE_freestyle_config_copy(FreestyleConfig *new_config, FreestyleConfig *con
new_config->dkr_epsilon = config->dkr_epsilon;
new_config->crease_angle = config->crease_angle;
- new_config->linesets.first = new_config->linesets.last = NULL;
+ BLI_listbase_clear(&new_config->linesets);
for (lineset = (FreestyleLineSet *)config->linesets.first; lineset; lineset = lineset->next) {
new_lineset = alloc_lineset();
copy_lineset(new_lineset, lineset);
BLI_addtail(&new_config->linesets, (void *)new_lineset);
}
- new_config->modules.first = new_config->modules.last = NULL;
+ BLI_listbase_clear(&new_config->modules);
for (module = (FreestyleModuleConfig *)config->modules.first; module; module = module->next) {
new_module = alloc_module();
copy_module(new_module, module);
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index 9bace5e1ee3..2eed25cde0e 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -61,7 +61,7 @@
bool free_gpencil_strokes(bGPDframe *gpf)
{
bGPDstroke *gps, *gpsn;
- bool changed = (gpf->strokes.first != NULL);
+ bool changed = (BLI_listbase_is_empty(&gpf->strokes) == false);
/* free strokes */
for (gps = gpf->strokes.first; gps; gps = gpsn) {
@@ -234,7 +234,7 @@ bGPDframe *gpencil_frame_duplicate(bGPDframe *src)
dst->prev = dst->next = NULL;
/* copy strokes */
- dst->strokes.first = dst->strokes.last = NULL;
+ BLI_listbase_clear(&dst->strokes);
for (gps = src->strokes.first; gps; gps = gps->next) {
/* make copy of source stroke, then adjust pointer to points too */
gpsd = MEM_dupallocN(gps);
@@ -262,7 +262,7 @@ bGPDlayer *gpencil_layer_duplicate(bGPDlayer *src)
dst->prev = dst->next = NULL;
/* copy frames */
- dst->frames.first = dst->frames.last = NULL;
+ BLI_listbase_clear(&dst->frames);
for (gpf = src->frames.first; gpf; gpf = gpf->next) {
/* make a copy of source frame */
gpfd = gpencil_frame_duplicate(gpf);
@@ -291,7 +291,7 @@ bGPdata *gpencil_data_duplicate(bGPdata *src)
dst = MEM_dupallocN(src);
/* copy layers */
- dst->layers.first = dst->layers.last = NULL;
+ BLI_listbase_clear(&dst->layers);
for (gpl = src->layers.first; gpl; gpl = gpl->next) {
/* make a copy of source layer and its data */
gpld = gpencil_layer_duplicate(gpl);
@@ -319,7 +319,7 @@ void gpencil_frame_delete_laststroke(bGPDlayer *gpl, bGPDframe *gpf)
BLI_freelinkN(&gpf->strokes, gps);
/* if frame has no strokes after this, delete it */
- if (gpf->strokes.first == NULL) {
+ if (BLI_listbase_is_empty(&gpf->strokes)) {
gpencil_layer_delframe(gpl, gpf);
gpencil_layer_getframe(gpl, cfra, 0);
}
diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c
index 82b6c0c04d5..2a61b2e7453 100644
--- a/source/blender/blenkernel/intern/group.c
+++ b/source/blender/blenkernel/intern/group.c
@@ -306,7 +306,7 @@ static void group_replaces_nla(Object *parent, Object *target, char mode)
if (done == 0) {
/* clear nla & action from object */
nlastrips = target->nlastrips;
- target->nlastrips.first = target->nlastrips.last = NULL;
+ BLI_listbase_clear(&target->nlastrips);
action = target->action;
target->action = NULL;
target->nlaflag |= OB_NLA_OVERRIDE;
@@ -323,7 +323,7 @@ static void group_replaces_nla(Object *parent, Object *target, char mode)
target->nlastrips = nlastrips;
target->action = action;
- nlastrips.first = nlastrips.last = NULL; /* not needed, but yah... :) */
+ BLI_listbase_clear(&nlastrips); /* not needed, but yah... :) */
action = NULL;
done = FALSE;
}
diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c
index d328c90aab3..08959850fb9 100644
--- a/source/blender/blenkernel/intern/implicit.c
+++ b/source/blender/blenkernel/intern/implicit.c
@@ -746,7 +746,7 @@ int implicit_init(Object *UNUSED(ob), ClothModifierData *clmd)
printf("implicit_init\n");
// init memory guard
- // MEMORY_BASE.first = MEMORY_BASE.last = NULL;
+ // BLI_listbase_clear(&MEMORY_BASE);
cloth = (Cloth *)clmd->clothObject;
verts = cloth->verts;
diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c
index 8ef3b7ef23d..cf66d866c2c 100644
--- a/source/blender/blenkernel/intern/ipo.c
+++ b/source/blender/blenkernel/intern/ipo.c
@@ -1455,7 +1455,7 @@ static void action_to_animato(ID *id, bAction *act, ListBase *groups, ListBase *
bConstraintChannel *conchan, *conchann;
/* only continue if there are Action Channels (indicating unconverted data) */
- if (act->chanbase.first == NULL)
+ if (BLI_listbase_is_empty(&act->chanbase))
return;
/* get rid of all Action Groups */
diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c
index d2080b4922c..93833f5c5ae 100644
--- a/source/blender/blenkernel/intern/key.c
+++ b/source/blender/blenkernel/intern/key.c
@@ -1397,7 +1397,7 @@ float *BKE_key_evaluate_object_ex(Scene *scene, Object *ob, int *r_totelem,
char *out;
int tot = 0, size = 0;
- if (key == NULL || key->block.first == NULL)
+ if (key == NULL || BLI_listbase_is_empty(&key->block))
return NULL;
/* compute size of output array */
diff --git a/source/blender/blenkernel/intern/linestyle.c b/source/blender/blenkernel/intern/linestyle.c
index 71c917d4528..3622174975a 100644
--- a/source/blender/blenkernel/intern/linestyle.c
+++ b/source/blender/blenkernel/intern/linestyle.c
@@ -90,10 +90,10 @@ static void default_linestyle_settings(FreestyleLineStyle *linestyle)
linestyle->max_length = 10000.0f;
linestyle->split_length = 100;
- linestyle->color_modifiers.first = linestyle->color_modifiers.last = NULL;
- linestyle->alpha_modifiers.first = linestyle->alpha_modifiers.last = NULL;
- linestyle->thickness_modifiers.first = linestyle->thickness_modifiers.last = NULL;
- linestyle->geometry_modifiers.first = linestyle->geometry_modifiers.last = NULL;
+ BLI_listbase_clear(&linestyle->color_modifiers);
+ BLI_listbase_clear(&linestyle->alpha_modifiers);
+ BLI_listbase_clear(&linestyle->thickness_modifiers);
+ BLI_listbase_clear(&linestyle->geometry_modifiers);
BKE_add_linestyle_geometry_modifier(linestyle, LS_MODIFIER_SAMPLING);
@@ -1005,7 +1005,8 @@ void BKE_list_modifier_color_ramps(FreestyleLineStyle *linestyle, ListBase *list
ColorBand *color_ramp;
LinkData *link;
- listbase->first = listbase->last = NULL;
+ BLI_listbase_clear(listbase);
+
for (m = (LineStyleModifier *)linestyle->color_modifiers.first; m; m = m->next) {
switch (m->type) {
case LS_MODIFIER_ALONG_STROKE:
diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c
index 33e758ed754..23c0401c1fe 100644
--- a/source/blender/blenkernel/intern/mask.c
+++ b/source/blender/blenkernel/intern/mask.c
@@ -742,8 +742,7 @@ Mask *BKE_mask_copy_nolib(Mask *mask)
/*take care here! - we may want to copy anim data */
mask_new->adt = NULL;
- mask_new->masklayers.first = NULL;
- mask_new->masklayers.last = NULL;
+ BLI_listbase_clear(&mask_new->masklayers);
BKE_mask_layer_copy_list(&mask_new->masklayers, &mask->masklayers);
@@ -762,8 +761,7 @@ Mask *BKE_mask_copy(Mask *mask)
mask_new = BKE_libblock_copy(&mask->id);
- mask_new->masklayers.first = NULL;
- mask_new->masklayers.last = NULL;
+ BLI_listbase_clear(&mask_new->masklayers);
BKE_mask_layer_copy_list(&mask_new->masklayers, &mask->masklayers);
@@ -1947,7 +1945,7 @@ int BKE_mask_get_duration(Mask *mask)
static void mask_clipboard_free_ex(bool final_free)
{
BKE_mask_spline_free_list(&mask_clipboard.splines);
- mask_clipboard.splines.first = mask_clipboard.splines.last = NULL;
+ BLI_listbase_clear(&mask_clipboard.splines);
if (mask_clipboard.id_hash) {
if (final_free) {
BLI_ghash_free(mask_clipboard.id_hash, NULL, MEM_freeN);
@@ -2005,7 +2003,7 @@ void BKE_mask_clipboard_copy_from_layer(MaskLayer *mask_layer)
/* Check clipboard is empty. */
bool BKE_mask_clipboard_is_empty(void)
{
- return mask_clipboard.splines.first == NULL;
+ return BLI_listbase_is_empty(&mask_clipboard.splines);
}
/* Paste the contents of clipboard to given mask layer */
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index 1cae95e99b3..5f6331315f8 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -245,7 +245,7 @@ Material *BKE_material_copy(Material *ma)
man->nodetree = ntreeCopyTree(ma->nodetree);
}
- man->gpumaterial.first = man->gpumaterial.last = NULL;
+ BLI_listbase_clear(&man->gpumaterial);
return man;
}
@@ -275,7 +275,7 @@ Material *localize_material(Material *ma)
if (ma->nodetree)
man->nodetree = ntreeLocalize(ma->nodetree);
- man->gpumaterial.first = man->gpumaterial.last = NULL;
+ BLI_listbase_clear(&man->gpumaterial);
return man;
}
@@ -1567,7 +1567,7 @@ void copy_matcopybuf(Material *ma)
}
matcopybuf.nodetree = ntreeCopyTree_ex(ma->nodetree, FALSE);
matcopybuf.preview = NULL;
- matcopybuf.gpumaterial.first = matcopybuf.gpumaterial.last = NULL;
+ BLI_listbase_clear(&matcopybuf.gpumaterial);
matcopied = 1;
}
diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c
index e5fdc449dbd..9e83d97b450 100644
--- a/source/blender/blenkernel/intern/mball.c
+++ b/source/blender/blenkernel/intern/mball.c
@@ -1901,8 +1901,7 @@ static void subdivide_metaball_octal_node(octal_node *node, float size_x, float
for (i = 0; i < 8; i++)
node->nodes[a]->nodes[i] = NULL;
node->nodes[a]->parent = node;
- node->nodes[a]->elems.first = NULL;
- node->nodes[a]->elems.last = NULL;
+ BLI_listbase_clear(&node->nodes[a]->elems);
node->nodes[a]->count = 0;
node->nodes[a]->neg = 0;
node->nodes[a]->pos = 0;
@@ -2171,8 +2170,7 @@ static void init_metaball_octal_tree(PROCESS *process, int depth)
process->metaball_tree->neg = node->neg = 0;
process->metaball_tree->pos = node->pos = 0;
- node->elems.first = NULL;
- node->elems.last = NULL;
+ BLI_listbase_clear(&node->elems);
node->count = 0;
for (a = 0; a < 8; a++)
@@ -2420,7 +2418,7 @@ bool BKE_mball_minmax(MetaBall *mb, float min[3], float max[3])
minmax_v3v3_v3(min, max, &ml->x);
}
- return (mb->elems.first != NULL);
+ return (BLI_listbase_is_empty(&mb->elems) == false);
}
bool BKE_mball_center_median(MetaBall *mb, float r_cent[3])
diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c
index 56796756ab5..06a12bdade1 100644
--- a/source/blender/blenkernel/intern/nla.c
+++ b/source/blender/blenkernel/intern/nla.c
@@ -152,7 +152,7 @@ void free_nladata(ListBase *tracks)
}
/* clear the list's pointers to be safe */
- tracks->first = tracks->last = NULL;
+ BLI_listbase_clear(tracks);
}
/* Copying ------------------------------------------- */
@@ -180,7 +180,7 @@ NlaStrip *copy_nlastrip(NlaStrip *strip)
copy_fmodifiers(&strip_d->modifiers, &strip->modifiers);
/* make a copy of all the child-strips, one at a time */
- strip_d->strips.first = strip_d->strips.last = NULL;
+ BLI_listbase_clear(&strip_d->strips);
for (cs = strip->strips.first; cs; cs = cs->next) {
cs_d = copy_nlastrip(cs);
@@ -206,7 +206,7 @@ NlaTrack *copy_nlatrack(NlaTrack *nlt)
nlt_d->next = nlt_d->prev = NULL;
/* make a copy of all the strips, one at a time */
- nlt_d->strips.first = nlt_d->strips.last = NULL;
+ BLI_listbase_clear(&nlt_d->strips);
for (strip = nlt->strips.first; strip; strip = strip->next) {
strip_d = copy_nlastrip(strip);
@@ -227,7 +227,7 @@ void copy_nladata(ListBase *dst, ListBase *src)
return;
/* clear out the destination list first for precautions... */
- dst->first = dst->last = NULL;
+ BLI_listbase_clear(dst);
/* copy each NLA-track, one at a time */
for (nlt = src->first; nlt; nlt = nlt->next) {
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index bc616934fef..27a8730fe03 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -1136,8 +1136,8 @@ static bNodeTree *ntreeCopyTree_internal(bNodeTree *ntree, Main *bmain, bool do_
/* in case a running nodetree is copied */
newtree->execdata = NULL;
- newtree->nodes.first = newtree->nodes.last = NULL;
- newtree->links.first = newtree->links.last = NULL;
+ BLI_listbase_clear(&newtree->nodes);
+ BLI_listbase_clear(&newtree->links);
last = ntree->nodes.last;
for (node = ntree->nodes.first; node; node = node->next) {
@@ -2538,13 +2538,13 @@ void BKE_node_clipboard_clear(void)
link_next = link->next;
nodeRemLink(NULL, link);
}
- node_clipboard.links.first = node_clipboard.links.last = NULL;
+ BLI_listbase_clear(&node_clipboard.links);
for (node = node_clipboard.nodes.first; node; node = node_next) {
node_next = node->next;
node_free_node_ex(NULL, node, false, false);
}
- node_clipboard.nodes.first = node_clipboard.nodes.last = NULL;
+ BLI_listbase_clear(&node_clipboard.nodes);
#ifdef USE_NODE_CB_VALIDATE
BLI_freelistN(&node_clipboard.nodes_extra_info);
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 05365a86828..6c9ffa5ab46 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -1014,7 +1014,7 @@ Object *BKE_object_add_only_object(Main *bmain, int type, const char *name)
/* NT fluid sim defaults */
ob->fluidsimSettings = NULL;
- ob->pc_ids.first = ob->pc_ids.last = NULL;
+ BLI_listbase_clear(&ob->pc_ids);
/* Animation Visualization defaults */
animviz_settings_init(&ob->avs);
@@ -1284,8 +1284,8 @@ static ParticleSystem *copy_particlesystem(ParticleSystem *psys)
psysn->effectors = NULL;
psysn->tree = NULL;
- psysn->pathcachebufs.first = psysn->pathcachebufs.last = NULL;
- psysn->childcachebufs.first = psysn->childcachebufs.last = NULL;
+ BLI_listbase_clear(&psysn->pathcachebufs);
+ BLI_listbase_clear(&psysn->childcachebufs);
psysn->renderdata = NULL;
psysn->pointcache = BKE_ptcache_copy_list(&psysn->ptcaches, &psys->ptcaches, FALSE);
@@ -1311,7 +1311,7 @@ void BKE_object_copy_particlesystems(Object *obn, Object *ob)
return;
}
- obn->particlesystem.first = obn->particlesystem.last = NULL;
+ BLI_listbase_clear(&obn->particlesystem);
for (psys = ob->particlesystem.first; psys; psys = psys->next) {
npsys = copy_particlesystem(psys);
@@ -1459,7 +1459,7 @@ Object *BKE_object_copy_ex(Main *bmain, Object *ob, int copy_caches)
if (ob->bb) obn->bb = MEM_dupallocN(ob->bb);
obn->flag &= ~OB_FROMGROUP;
- obn->modifiers.first = obn->modifiers.last = NULL;
+ BLI_listbase_clear(&obn->modifiers);
for (md = ob->modifiers.first; md; md = md->next) {
ModifierData *nmd = modifier_new(md->type);
@@ -1468,7 +1468,7 @@ Object *BKE_object_copy_ex(Main *bmain, Object *ob, int copy_caches)
BLI_addtail(&obn->modifiers, nmd);
}
- obn->prop.first = obn->prop.last = NULL;
+ BLI_listbase_clear(&obn->prop);
BKE_bproperty_copy_list(&obn->prop, &ob->prop);
copy_sensors(&obn->sensors, &ob->sensors);
@@ -1516,8 +1516,8 @@ Object *BKE_object_copy_ex(Main *bmain, Object *ob, int copy_caches)
obn->derivedDeform = NULL;
obn->derivedFinal = NULL;
- obn->gpulamp.first = obn->gpulamp.last = NULL;
- obn->pc_ids.first = obn->pc_ids.last = NULL;
+ BLI_listbase_clear(&obn->gpulamp);
+ BLI_listbase_clear(&obn->pc_ids);
obn->mpath = NULL;
diff --git a/source/blender/blenkernel/intern/object_deform.c b/source/blender/blenkernel/intern/object_deform.c
index 77c5e57f382..f313c098f4b 100644
--- a/source/blender/blenkernel/intern/object_deform.c
+++ b/source/blender/blenkernel/intern/object_deform.c
@@ -29,6 +29,7 @@
#include "BLI_utildefines.h"
#include "BLI_ghash.h"
+#include "BLI_listbase.h"
#include "BKE_action.h"
#include "BKE_object_deform.h" /* own include */
@@ -75,7 +76,7 @@ bool *BKE_objdef_validmap_get(Object *ob, const int defbase_tot)
//int defbase_tot = BLI_countlist(&ob->defbase);
VirtualModifierData virtualModifierData;
- if (ob->defbase.first == NULL) {
+ if (BLI_listbase_is_empty(&ob->defbase)) {
return NULL;
}
diff --git a/source/blender/blenkernel/intern/object_dupli.c b/source/blender/blenkernel/intern/object_dupli.c
index dd9f1a268b2..74426df58c7 100644
--- a/source/blender/blenkernel/intern/object_dupli.c
+++ b/source/blender/blenkernel/intern/object_dupli.c
@@ -337,7 +337,7 @@ static void make_duplis_frames(const DupliContext *ctx)
/* if we don't have any data/settings which will lead to object movement,
* don't waste time trying, as it will all look the same...
*/
- if (ob->parent == NULL && ob->constraints.first == NULL && ob->adt == NULL)
+ if (ob->parent == NULL && BLI_listbase_is_empty(&ob->constraints) && ob->adt == NULL)
return;
/* make a copy of the object's original data (before any dupli-data overwrites it)
@@ -877,7 +877,7 @@ static void make_duplis_particle_system(const DupliContext *ctx, ParticleSystem
return;
}
else { /*PART_DRAW_GR */
- if (part->dup_group == NULL || part->dup_group->gobject.first == NULL)
+ if (part->dup_group == NULL || BLI_listbase_is_empty(&part->dup_group->gobject))
return;
if (BLI_findptr(&part->dup_group->gobject, par, offsetof(GroupObject, ob))) {
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 8e256f05f71..edf902e0eb5 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -411,7 +411,7 @@ void free_hair(Object *UNUSED(ob), ParticleSystem *psys, int dynamics)
if (dynamics) {
BKE_ptcache_free_list(&psys->ptcaches);
psys->clmd->point_cache = psys->pointcache = NULL;
- psys->clmd->ptcaches.first = psys->clmd->ptcaches.last = NULL;
+ BLI_listbase_clear(&psys->clmd->ptcaches);
modifier_free((ModifierData *)psys->clmd);
@@ -712,8 +712,8 @@ void psys_render_set(Object *ob, ParticleSystem *psys, float viewmat[4][4], floa
psys->pathcache = NULL;
psys->childcache = NULL;
psys->totchild = psys->totcached = psys->totchildcache = 0;
- psys->pathcachebufs.first = psys->pathcachebufs.last = NULL;
- psys->childcachebufs.first = psys->childcachebufs.last = NULL;
+ BLI_listbase_clear(&psys->pathcachebufs);
+ BLI_listbase_clear(&psys->childcachebufs);
copy_m4_m4(data->winmat, winmat);
mul_m4_m4m4(data->viewmat, viewmat, ob->obmat);
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index 6ae3e2e9d5e..71b91340721 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -2180,7 +2180,7 @@ void psys_make_temp_pointcache(Object *ob, ParticleSystem *psys)
{
PointCache *cache = psys->pointcache;
- if (cache->flag & PTCACHE_DISK_CACHE && cache->mem_cache.first == NULL) {
+ if (cache->flag & PTCACHE_DISK_CACHE && BLI_listbase_is_empty(&cache->mem_cache)) {
PTCacheID pid;
BKE_ptcache_id_from_particles(&pid, ob, psys);
cache->flag &= ~PTCACHE_DISK_CACHE;
@@ -3597,7 +3597,7 @@ static int collision_detect(ParticleData *pa, ParticleCollision *col, BVHTreeRay
ColliderCache *coll;
float ray_dir[3];
- if (colliders->first == NULL)
+ if (BLI_listbase_is_empty(colliders))
return 0;
sub_v3_v3v3(ray_dir, col->co2, col->co1);
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index 271160a54f0..df6534946fd 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -3045,12 +3045,9 @@ static PointCache *ptcache_copy(PointCache *cache, int copy_data)
ncache= MEM_dupallocN(cache);
- ncache->mem_cache.first = NULL;
- ncache->mem_cache.last = NULL;
+ BLI_listbase_clear(&ncache->mem_cache);
if (copy_data == FALSE) {
- ncache->mem_cache.first = NULL;
- ncache->mem_cache.last = NULL;
ncache->cached_frames = NULL;
/* flag is a mix of user settings and simulator/baking state */
@@ -3089,7 +3086,7 @@ PointCache *BKE_ptcache_copy_list(ListBase *ptcaches_new, ListBase *ptcaches_old
{
PointCache *cache = ptcaches_old->first;
- ptcaches_new->first = ptcaches_new->last = NULL;
+ BLI_listbase_clear(ptcaches_new);
for (; cache; cache=cache->next)
BLI_addtail(ptcaches_new, ptcache_copy(cache, copy_data));
diff --git a/source/blender/blenkernel/intern/report.c b/source/blender/blenkernel/intern/report.c
index 1fd7dc14c23..3d0713f9514 100644
--- a/source/blender/blenkernel/intern/report.c
+++ b/source/blender/blenkernel/intern/report.c
@@ -97,7 +97,7 @@ void BKE_reports_clear(ReportList *reports)
report = report_next;
}
- reports->list.first = reports->list.last = NULL;
+ BLI_listbase_clear(&reports->list);
}
void BKE_report(ReportList *reports, ReportType type, const char *_message)
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 922b3860f7e..09bfdbb2d95 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -729,7 +729,7 @@ static void scene_unlink_space_node(SpaceNode *snode, Scene *sce)
path_next = path->next;
MEM_freeN(path);
}
- snode->treepath.first = snode->treepath.last = NULL;
+ BLI_listbase_clear(&snode->treepath);
snode->id = NULL;
snode->from = NULL;
diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c
index 5bfd5e67eb1..ab725ae04a9 100644
--- a/source/blender/blenkernel/intern/screen.c
+++ b/source/blender/blenkernel/intern/screen.c
@@ -171,11 +171,11 @@ ARegion *BKE_area_region_copy(SpaceType *st, ARegion *ar)
Panel *pa, *newpa, *patab;
newar->prev = newar->next = NULL;
- newar->handlers.first = newar->handlers.last = NULL;
- newar->uiblocks.first = newar->uiblocks.last = NULL;
- newar->panels_category.first = newar->panels_category.last = NULL;
- newar->panels_category_active.first = newar->panels_category_active.last = NULL;
- newar->ui_lists.first = newar->ui_lists.last = NULL;
+ BLI_listbase_clear(&newar->handlers);
+ BLI_listbase_clear(&newar->uiblocks);
+ BLI_listbase_clear(&newar->panels_category);
+ BLI_listbase_clear(&newar->panels_category_active);
+ BLI_listbase_clear(&newar->ui_lists);
newar->swinid = 0;
/* use optional regiondata callback */
@@ -191,7 +191,7 @@ ARegion *BKE_area_region_copy(SpaceType *st, ARegion *ar)
if (ar->v2d.tab_offset)
newar->v2d.tab_offset = MEM_dupallocN(ar->v2d.tab_offset);
- newar->panels.first = newar->panels.last = NULL;
+ BLI_listbase_clear(&newar->panels);
BLI_duplicatelist(&newar->panels, &ar->panels);
/* copy panel pointers */
@@ -218,7 +218,7 @@ static void region_copylist(SpaceType *st, ListBase *lb1, ListBase *lb2)
ARegion *ar;
/* to be sure */
- lb1->first = lb1->last = NULL;
+ BLI_listbase_clear(lb1);
for (ar = lb2->first; ar; ar = ar->next) {
ARegion *arnew = BKE_area_region_copy(st, ar);
@@ -232,7 +232,7 @@ void BKE_spacedata_copylist(ListBase *lb1, ListBase *lb2)
{
SpaceLink *sl;
- lb1->first = lb1->last = NULL; /* to be sure */
+ BLI_listbase_clear(lb1); /* to be sure */
for (sl = lb2->first; sl; sl = sl->next) {
SpaceType *st = BKE_spacetype_from_id(sl->spacetype);
diff --git a/source/blender/blenkernel/intern/seqcache.c b/source/blender/blenkernel/intern/seqcache.c
index a85e70d2afc..97062f728c5 100644
--- a/source/blender/blenkernel/intern/seqcache.c
+++ b/source/blender/blenkernel/intern/seqcache.c
@@ -257,7 +257,7 @@ void BKE_sequencer_preprocessed_cache_cleanup(void)
}
BLI_freelistN(&preprocess_cache->elems);
- preprocess_cache->elems.first = preprocess_cache->elems.last = NULL;
+ BLI_listbase_clear(&preprocess_cache->elems);
}
static void preprocessed_cache_destruct(void)
diff --git a/source/blender/blenkernel/intern/seqmodifier.c b/source/blender/blenkernel/intern/seqmodifier.c
index b3b5fc1e8d0..27d09eeaf8f 100644
--- a/source/blender/blenkernel/intern/seqmodifier.c
+++ b/source/blender/blenkernel/intern/seqmodifier.c
@@ -622,7 +622,7 @@ void BKE_sequence_modifier_clear(Sequence *seq)
BKE_sequence_modifier_free(smd);
}
- seq->modifiers.first = seq->modifiers.last = NULL;
+ BLI_listbase_clear(&seq->modifiers);
}
void BKE_sequence_modifier_free(SequenceModifierData *smd)
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c
index 675c7dcea95..54cff24bb76 100644
--- a/source/blender/blenkernel/intern/sequencer.c
+++ b/source/blender/blenkernel/intern/sequencer.c
@@ -279,7 +279,7 @@ void BKE_sequencer_free_clipboard(void)
nseq = seq->next;
seq_free_clipboard_recursive(seq);
}
- seqbase_clipboard.first = seqbase_clipboard.last = NULL;
+ BLI_listbase_clear(&seqbase_clipboard);
}
/* -------------------------------------------------------------------- */
@@ -880,8 +880,8 @@ void BKE_sequencer_sort(Scene *scene)
if (ed == NULL)
return;
- seqbase.first = seqbase.last = NULL;
- effbase.first = effbase.last = NULL;
+ BLI_listbase_clear(&seqbase);
+ BLI_listbase_clear(&effbase);
while ((seq = BLI_pophead(ed->seqbasep))) {
@@ -2502,7 +2502,7 @@ static ImBuf *seq_render_scene_strip(const SeqRenderData *context, Sequence *seq
#ifdef DURIAN_CAMERA_SWITCH
/* stooping to new low's in hackyness :( */
oldmarkers = scene->markers;
- scene->markers.first = scene->markers.last = NULL;
+ BLI_listbase_clear(&scene->markers);
#else
(void)oldmarkers;
#endif
@@ -4381,7 +4381,7 @@ static Sequence *seq_dupli(Scene *scene, Scene *scene_to, Sequence *seq, int dup
}
if (seqn->modifiers.first) {
- seqn->modifiers.first = seqn->modifiers.last = NULL;
+ BLI_listbase_clear(&seqn->modifiers);
BKE_sequence_modifier_list_copy(seqn, seq);
}
@@ -4389,7 +4389,7 @@ static Sequence *seq_dupli(Scene *scene, Scene *scene_to, Sequence *seq, int dup
if (seq->type == SEQ_TYPE_META) {
seqn->strip->stripdata = NULL;
- seqn->seqbase.first = seqn->seqbase.last = NULL;
+ BLI_listbase_clear(&seqn->seqbase);
/* WATCH OUT!!! - This metastrip is not recursively duplicated here - do this after!!! */
/* - seq_dupli_recursive(&seq->seqbase, &seqn->seqbase);*/
}
diff --git a/source/blender/blenkernel/intern/sketch.c b/source/blender/blenkernel/intern/sketch.c
index bbd637a0a77..da5dd76681d 100644
--- a/source/blender/blenkernel/intern/sketch.c
+++ b/source/blender/blenkernel/intern/sketch.c
@@ -64,8 +64,7 @@ SK_Sketch *createSketch(void)
sketch->active_stroke = NULL;
sketch->gesture = NULL;
- sketch->strokes.first = NULL;
- sketch->strokes.last = NULL;
+ BLI_listbase_clear(&sketch->strokes);
return sketch;
}
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c
index 8636614f7ed..6aaf2ee4df0 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -523,7 +523,7 @@ void smokeModifier_createType(struct SmokeModifierData *smd)
/* Deprecated */
smd->domain->point_cache[1] = NULL;
- smd->domain->ptcaches[1].first = smd->domain->ptcaches[1].last = NULL;
+ BLI_listbase_clear(&smd->domain->ptcaches[1]);
/* set some standard values */
smd->domain->fluid = NULL;
smd->domain->fluid_mutex = BLI_rw_mutex_alloc();
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c
index 829354ce662..e1396c022cb 100644
--- a/source/blender/blenkernel/intern/text.c
+++ b/source/blender/blenkernel/intern/text.c
@@ -188,7 +188,7 @@ Text *BKE_text_add(Main *bmain, const char *name)
if ((U.flag & USER_TXT_TABSTOSPACES_DISABLE) == 0)
ta->flags |= TXT_TABSTOSPACES;
- ta->lines.first = ta->lines.last = NULL;
+ BLI_listbase_clear(&ta->lines);
tmp = (TextLine *) MEM_mallocN(sizeof(TextLine), "textline");
tmp->line = (char *) MEM_mallocN(1, "textline_string");
@@ -293,7 +293,7 @@ int BKE_text_reload(Text *text)
BLI_freelistN(&text->lines);
- text->lines.first = text->lines.last = NULL;
+ BLI_listbase_clear(&text->lines);
text->curl = text->sell = NULL;
/* clear undo buffer */
@@ -382,7 +382,7 @@ Text *BKE_text_load_ex(Main *bmain, const char *file, const char *relpath, const
ta = BKE_libblock_alloc(bmain, ID_TXT, BLI_path_basename(str));
ta->id.us = 1;
- ta->lines.first = ta->lines.last = NULL;
+ BLI_listbase_clear(&ta->lines);
ta->curl = ta->sell = NULL;
if ((U.flag & USER_TXT_TABSTOSPACES_DISABLE) == 0)
@@ -488,7 +488,7 @@ Text *BKE_text_copy(Text *ta)
tan->flags = ta->flags | TXT_ISDIRTY;
- tan->lines.first = tan->lines.last = NULL;
+ BLI_listbase_clear(&tan->lines);
tan->curl = tan->sell = NULL;
tan->nlines = ta->nlines;
diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c
index fbca675e5ee..de20f4a8ac6 100644
--- a/source/blender/blenkernel/intern/tracking.c
+++ b/source/blender/blenkernel/intern/tracking.c
@@ -163,8 +163,8 @@ static void tracking_dopesheet_free(MovieTrackingDopesheet *dopesheet)
BLI_freelistN(&dopesheet->coverage_segments);
/* Ensure lists are clean. */
- dopesheet->channels.first = dopesheet->channels.last = NULL;
- dopesheet->coverage_segments.first = dopesheet->coverage_segments.last = NULL;
+ BLI_listbase_clear(&dopesheet->channels);
+ BLI_listbase_clear(&dopesheet->coverage_segments);
dopesheet->tot_channel = 0;
}
@@ -330,7 +330,7 @@ void BKE_tracking_clipboard_free(void)
track = next_track;
}
- tracking_clipboard.tracks.first = tracking_clipboard.tracks.last = NULL;
+ BLI_listbase_clear(&tracking_clipboard.tracks);
}
/* Copy selected tracks from specified object to the clipboard. */
@@ -357,7 +357,7 @@ void BKE_tracking_clipboard_copy_tracks(MovieTracking *tracking, MovieTrackingOb
/* Check whether there're any tracks in the clipboard. */
bool BKE_tracking_clipboard_has_tracks(void)
{
- return tracking_clipboard.tracks.first != NULL;
+ return (BLI_listbase_is_empty(&tracking_clipboard.tracks) == false);
}
/* Paste tracks from clipboard to specified object.
diff --git a/source/blender/blenlib/BLI_listbase.h b/source/blender/blenlib/BLI_listbase.h
index 0927620a2c6..77490929efb 100644
--- a/source/blender/blenlib/BLI_listbase.h
+++ b/source/blender/blenlib/BLI_listbase.h
@@ -77,6 +77,13 @@ void BLI_reverselist(struct ListBase *lb);
void BLI_rotatelist_first(struct ListBase *lb, void *vlink);
void BLI_rotatelist_last(struct ListBase *lb, void *vlink);
+/**
+ * Utility functions to avoid first/last references inline all over.
+ */
+BLI_INLINE bool BLI_listbase_is_single(const struct ListBase *lb) { return (lb->first && lb->first == lb->last); }
+BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb) { return (lb->first == NULL); }
+BLI_INLINE void BLI_listbase_clear(struct ListBase *lb) { lb->first = lb->last = NULL; }
+
/* create a generic list node containing link to provided data */
struct LinkData *BLI_genericNodeN(void *data);
diff --git a/source/blender/blenlib/intern/BLI_args.c b/source/blender/blenlib/intern/BLI_args.c
index fdef0d69539..fb35b55a935 100644
--- a/source/blender/blenlib/intern/BLI_args.c
+++ b/source/blender/blenlib/intern/BLI_args.c
@@ -122,7 +122,7 @@ bArgs *BLI_argsInit(int argc, const char **argv)
bArgs *ba = MEM_callocN(sizeof(bArgs), "bArgs");
ba->passes = MEM_callocN(sizeof(int) * argc, "bArgs passes");
ba->items = BLI_ghash_new(keyhash, keycmp, "bArgs passes gh");
- ba->docs.first = ba->docs.last = NULL;
+ BLI_listbase_clear(&ba->docs);
ba->argc = argc;
ba->argv = argv;
diff --git a/source/blender/blenlib/intern/BLI_mempool.c b/source/blender/blenlib/intern/BLI_mempool.c
index 1321f006e36..7dc43bb1494 100644
--- a/source/blender/blenlib/intern/BLI_mempool.c
+++ b/source/blender/blenlib/intern/BLI_mempool.c
@@ -233,7 +233,7 @@ static void mempool_chunk_free_all(ListBase *chunks, const unsigned int flag)
mpchunk_next = mpchunk->next;
mempool_chunk_free(mpchunk, flag);
}
- chunks->first = chunks->last = NULL;
+ BLI_listbase_clear(chunks);
}
BLI_mempool *BLI_mempool_create(unsigned int esize, unsigned int totelem,
@@ -268,7 +268,7 @@ BLI_mempool *BLI_mempool_create(unsigned int esize, unsigned int totelem,
pool->flag = flag;
pool->pchunk = pchunk;
pool->csize = esize * pchunk;
- pool->chunks.first = pool->chunks.last = NULL;
+ BLI_listbase_clear(&pool->chunks);
pool->free = NULL; /* mempool_chunk_add assigns */
pool->maxchunks = maxchunks;
#ifdef USE_TOTALLOC
@@ -598,7 +598,7 @@ void BLI_mempool_clear_ex(BLI_mempool *pool, const int totelem_reserve)
#endif
chunks_temp = pool->chunks;
- pool->chunks.first = pool->chunks.last = NULL;
+ BLI_listbase_clear(&pool->chunks);
while ((mpchunk = BLI_pophead(&chunks_temp))) {
lasttail = mempool_chunk_add(pool, mpchunk, lasttail);
diff --git a/source/blender/blenlib/intern/scanfill.c b/source/blender/blenlib/intern/scanfill.c
index 46ab2db87f5..ae0760eb30e 100644
--- a/source/blender/blenlib/intern/scanfill.c
+++ b/source/blender/blenlib/intern/scanfill.c
@@ -754,9 +754,9 @@ void BLI_scanfill_end(ScanFillContext *sf_ctx)
BLI_memarena_free(sf_ctx->arena);
sf_ctx->arena = NULL;
- sf_ctx->fillvertbase.first = sf_ctx->fillvertbase.last = NULL;
- sf_ctx->filledgebase.first = sf_ctx->filledgebase.last = NULL;
- sf_ctx->fillfacebase.first = sf_ctx->fillfacebase.last = NULL;
+ BLI_listbase_clear(&sf_ctx->fillvertbase);
+ BLI_listbase_clear(&sf_ctx->filledgebase);
+ BLI_listbase_clear(&sf_ctx->fillfacebase);
}
void BLI_scanfill_end_arena(ScanFillContext *sf_ctx, MemArena *arena)
@@ -764,9 +764,9 @@ void BLI_scanfill_end_arena(ScanFillContext *sf_ctx, MemArena *arena)
BLI_memarena_clear(arena);
BLI_assert(sf_ctx->arena == arena);
- sf_ctx->fillvertbase.first = sf_ctx->fillvertbase.last = NULL;
- sf_ctx->filledgebase.first = sf_ctx->filledgebase.last = NULL;
- sf_ctx->fillfacebase.first = sf_ctx->fillfacebase.last = NULL;
+ BLI_listbase_clear(&sf_ctx->fillvertbase);
+ BLI_listbase_clear(&sf_ctx->filledgebase);
+ BLI_listbase_clear(&sf_ctx->fillfacebase);
}
unsigned int BLI_scanfill_calc_ex(ScanFillContext *sf_ctx, const int flag, const float nor_proj[3])
@@ -994,7 +994,7 @@ unsigned int BLI_scanfill_calc_ex(ScanFillContext *sf_ctx, const int flag, const
}
}
}
- if (sf_ctx->filledgebase.first == NULL) {
+ if (BLI_listbase_is_empty(&sf_ctx->filledgebase)) {
/* printf("All edges removed\n"); */
return 0;
}
@@ -1112,8 +1112,8 @@ unsigned int BLI_scanfill_calc_ex(ScanFillContext *sf_ctx, const int flag, const
tempve.last = sf_ctx->fillvertbase.last;
temped.first = sf_ctx->filledgebase.first;
temped.last = sf_ctx->filledgebase.last;
- sf_ctx->fillvertbase.first = sf_ctx->fillvertbase.last = NULL;
- sf_ctx->filledgebase.first = sf_ctx->filledgebase.last = NULL;
+ BLI_listbase_clear(&sf_ctx->fillvertbase);
+ BLI_listbase_clear(&sf_ctx->filledgebase);
pf = pflist;
for (a = 0; a < poly; a++) {
diff --git a/source/blender/blenlib/intern/task.c b/source/blender/blenlib/intern/task.c
index 1ac4045ea49..8d867b9f295 100644
--- a/source/blender/blenlib/intern/task.c
+++ b/source/blender/blenlib/intern/task.c
@@ -156,7 +156,7 @@ TaskScheduler *BLI_task_scheduler_create(int num_threads)
* threads, so we keep track of the number of users. */
scheduler->do_exit = false;
- scheduler->queue.first = scheduler->queue.last = NULL;
+ BLI_listbase_clear(&scheduler->queue);
BLI_mutex_init(&scheduler->queue_mutex);
BLI_condition_init(&scheduler->queue_cond);
diff --git a/source/blender/blenlib/intern/threads.c b/source/blender/blenlib/intern/threads.c
index 0b8f5dfdde5..5d8c1af6c7f 100644
--- a/source/blender/blenlib/intern/threads.c
+++ b/source/blender/blenlib/intern/threads.c
@@ -184,7 +184,7 @@ void BLI_init_threads(ListBase *threadbase, void *(*do_thread)(void *), int tot)
int a;
if (threadbase != NULL && tot > 0) {
- threadbase->first = threadbase->last = NULL;
+ BLI_listbase_clear(threadbase);
if (tot > RE_MAX_THREAD) tot = RE_MAX_THREAD;
else if (tot < 1) tot = 1;
@@ -318,7 +318,7 @@ void BLI_end_threads(ListBase *threadbase)
/* only needed if there's actually some stuff to end
* this way we don't end up decrementing thread_levels on an empty threadbase
* */
- if (threadbase && threadbase->first != NULL) {
+ if (threadbase && (BLI_listbase_is_empty(threadbase) == false)) {
for (tslot = threadbase->first; tslot; tslot = tslot->next) {
if (tslot->avail == 0) {
pthread_join(tslot->pthread, NULL);
diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c
index b03d250e868..5dcf875a32b 100644
--- a/source/blender/blenloader/intern/readblenentry.c
+++ b/source/blender/blenloader/intern/readblenentry.c
@@ -326,7 +326,7 @@ BlendFileData *BLO_read_from_memfile(Main *oldmain, const char *filename, MemFil
/* Library structs themselves */
bfd->main->library = oldmain->library;
- oldmain->library.first = oldmain->library.last = NULL;
+ BLI_listbase_clear(&oldmain->library);
/* add the Library mainlist to the new main */
BLI_remlink(&mainlist, oldmain);
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 738b682188a..f41baf5553a 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -489,7 +489,7 @@ void blo_split_main(ListBase *mainlist, Main *main)
mainlist->first = mainlist->last = main;
main->next = NULL;
- if (main->library.first == NULL)
+ if (BLI_listbase_is_empty(&main->library))
return;
for (lib = main->library.first; lib; lib = lib->id.next) {
@@ -1573,7 +1573,7 @@ static void link_list(FileData *fd, ListBase *lb) /* only direct data */
{
Link *ln, *prev;
- if (lb->first == NULL) return;
+ if (BLI_listbase_is_empty(lb)) return;
lb->first = newdataadr(fd, lb->first);
ln = lb->first;
@@ -1592,7 +1592,7 @@ static void link_glob_list(FileData *fd, ListBase *lb) /* for glob data */
Link *ln, *prev;
void *poin;
- if (lb->first == NULL) return;
+ if (BLI_listbase_is_empty(lb)) return;
poin = newdataadr(fd, lb->first);
if (lb->first) {
oldnewmap_insert(fd->globmap, lb->first, poin, 0);
@@ -3127,7 +3127,7 @@ static void direct_link_mball(FileData *fd, MetaBall *mb)
link_list(fd, &(mb->elems));
- mb->disp.first = mb->disp.last = NULL;
+ BLI_listbase_clear(&mb->disp);
mb->editelems = NULL;
/* mb->edit_elems.first= mb->edit_elems.last= NULL;*/
mb->lastelem = NULL;
@@ -3539,7 +3539,7 @@ static void direct_link_material(FileData *fd, Material *ma)
}
ma->preview = direct_link_preview_image(fd, ma->preview);
- ma->gpumaterial.first = ma->gpumaterial.last = NULL;
+ BLI_listbase_clear(&ma->gpumaterial);
}
/* ************ READ PARTICLE SETTINGS ***************** */
@@ -3585,7 +3585,7 @@ static void direct_link_pointcache(FileData *fd, PointCache *cache)
}
}
else
- cache->mem_cache.first = cache->mem_cache.last = NULL;
+ BLI_listbase_clear(&cache->mem_cache);
cache->flag &= ~PTCACHE_SIMULATION_VALID;
cache->simframe = 0;
@@ -3656,7 +3656,7 @@ static void lib_link_particlesettings(FileData *fd, Main *main)
if (part->dupliweights.first && part->dup_group) {
int index_ok = 0;
/* check for old files without indices (all indexes 0) */
- if (part->dupliweights.first == part->dupliweights.last) {
+ if (BLI_listbase_is_single(&part->dupliweights)) {
/* special case for only one object in the group */
index_ok = 1;
}
@@ -3684,7 +3684,7 @@ static void lib_link_particlesettings(FileData *fd, Main *main)
}
}
else {
- part->dupliweights.first = part->dupliweights.last = NULL;
+ BLI_listbase_clear(&part->dupliweights);
}
if (part->boids) {
@@ -3847,8 +3847,8 @@ static void direct_link_particlesystems(FileData *fd, ListBase *particles)
psys->free_edit = NULL;
psys->pathcache = NULL;
psys->childcache = NULL;
- psys->pathcachebufs.first = psys->pathcachebufs.last = NULL;
- psys->childcachebufs.first = psys->childcachebufs.last = NULL;
+ BLI_listbase_clear(&psys->pathcachebufs);
+ BLI_listbase_clear(&psys->childcachebufs);
psys->frand = NULL;
psys->pdd = NULL;
psys->renderdata = NULL;
@@ -4540,8 +4540,8 @@ static void direct_link_pose(FileData *fd, bPose *pose)
if (pchan->mpath)
direct_link_motionpath(fd, pchan->mpath);
- pchan->iktree.first = pchan->iktree.last = NULL;
- pchan->siktree.first = pchan->siktree.last = NULL;
+ BLI_listbase_clear(&pchan->iktree);
+ BLI_listbase_clear(&pchan->siktree);
/* in case this value changes in future, clamp else we get undefined behavior */
CLAMP(pchan->rotmode, ROT_MODE_MIN, ROT_MODE_MAX);
@@ -4643,8 +4643,7 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
}
BKE_ptcache_free(cache);
}
- smd->domain->ptcaches[1].first = NULL;
- smd->domain->ptcaches[1].last = NULL;
+ BLI_listbase_clear(&smd->domain->ptcaches[1]);
smd->domain->point_cache[1] = NULL;
}
}
@@ -5036,7 +5035,7 @@ static void direct_link_object(FileData *fd, Object *ob)
ob->bb = NULL;
ob->derivedDeform = NULL;
ob->derivedFinal = NULL;
- ob->gpulamp.first= ob->gpulamp.last = NULL;
+ BLI_listbase_clear(&ob->gpulamp);
link_list(fd, &ob->pc_ids);
/* Runtime curve data */
@@ -5519,11 +5518,11 @@ static void direct_link_windowmanager(FileData *fd, wmWindowManager *wm)
win->curswin = NULL;
win->tweak = NULL;
- win->queue.first = win->queue.last = NULL;
- win->handlers.first = win->handlers.last = NULL;
- win->modalhandlers.first = win->modalhandlers.last = NULL;
- win->subwindows.first = win->subwindows.last = NULL;
- win->gesture.first = win->gesture.last = NULL;
+ BLI_listbase_clear(&win->queue);
+ BLI_listbase_clear(&win->handlers);
+ BLI_listbase_clear(&win->modalhandlers);
+ BLI_listbase_clear(&win->subwindows);
+ BLI_listbase_clear(&win->gesture);
win->drawdata = NULL;
win->drawmethod = -1;
@@ -5535,19 +5534,19 @@ static void direct_link_windowmanager(FileData *fd, wmWindowManager *wm)
win->modalcursor = 0;
}
- wm->timers.first = wm->timers.last = NULL;
- wm->operators.first = wm->operators.last = NULL;
- wm->paintcursors.first = wm->paintcursors.last = NULL;
- wm->queue.first = wm->queue.last = NULL;
+ BLI_listbase_clear(&wm->timers);
+ BLI_listbase_clear(&wm->operators);
+ BLI_listbase_clear(&wm->paintcursors);
+ BLI_listbase_clear(&wm->queue);
BKE_reports_init(&wm->reports, RPT_STORE);
- wm->keyconfigs.first = wm->keyconfigs.last = NULL;
+ BLI_listbase_clear(&wm->keyconfigs);
wm->defaultconf = NULL;
wm->addonconf = NULL;
wm->userconf = NULL;
- wm->jobs.first = wm->jobs.last = NULL;
- wm->drags.first = wm->drags.last = NULL;
+ BLI_listbase_clear(&wm->jobs);
+ BLI_listbase_clear(&wm->drags);
wm->windrawable = NULL;
wm->winactive = NULL;
@@ -6189,9 +6188,9 @@ static void direct_link_region(FileData *fd, ARegion *ar, int spacetype)
ar->v2d.tab_num = 0;
ar->v2d.tab_cur = 0;
ar->v2d.sms = NULL;
- ar->panels_category.first = ar->panels_category.last = NULL;
- ar->handlers.first = ar->handlers.last = NULL;
- ar->uiblocks.first = ar->uiblocks.last = NULL;
+ BLI_listbase_clear(&ar->panels_category);
+ BLI_listbase_clear(&ar->handlers);
+ BLI_listbase_clear(&ar->uiblocks);
ar->headerstr = NULL;
ar->swinid = 0;
ar->type = NULL;
@@ -6266,7 +6265,7 @@ static bool direct_link_screen(FileData *fd, bScreen *sc)
link_list(fd, &(sa->spacedata));
link_list(fd, &(sa->regionbase));
- sa->handlers.first = sa->handlers.last = NULL;
+ BLI_listbase_clear(&sa->handlers);
sa->type = NULL; /* spacetype callbacks */
sa->region_active_win = -1;
@@ -6323,9 +6322,9 @@ static bool direct_link_screen(FileData *fd, bScreen *sc)
direct_link_gpencil(fd, v3d->gpd);
}
v3d->localvd = newdataadr(fd, v3d->localvd);
- v3d->afterdraw_transp.first = v3d->afterdraw_transp.last = NULL;
- v3d->afterdraw_xray.first = v3d->afterdraw_xray.last = NULL;
- v3d->afterdraw_xraytransp.first = v3d->afterdraw_xraytransp.last = NULL;
+ BLI_listbase_clear(&v3d->afterdraw_transp);
+ BLI_listbase_clear(&v3d->afterdraw_xray);
+ BLI_listbase_clear(&v3d->afterdraw_xraytransp);
v3d->properties_storage = NULL;
v3d->defmaterial = NULL;
@@ -6339,7 +6338,7 @@ static bool direct_link_screen(FileData *fd, bScreen *sc)
SpaceIpo *sipo = (SpaceIpo *)sl;
sipo->ads = newdataadr(fd, sipo->ads);
- sipo->ghostCurves.first = sipo->ghostCurves.last = NULL;
+ BLI_listbase_clear(&sipo->ghostCurves);
}
else if (sl->spacetype == SPACE_NLA) {
SpaceNla *snla = (SpaceNla *)sl;
@@ -6407,7 +6406,7 @@ static bool direct_link_screen(FileData *fd, bScreen *sc)
link_list(fd, &snode->treepath);
snode->edittree = NULL;
- snode->linkdrag.first = snode->linkdrag.last = NULL;
+ BLI_listbase_clear(&snode->linkdrag);
}
else if (sl->spacetype == SPACE_TEXT) {
SpaceText *st= (SpaceText *)sl;
@@ -6418,7 +6417,7 @@ static bool direct_link_screen(FileData *fd, bScreen *sc)
}
else if (sl->spacetype == SPACE_TIME) {
SpaceTime *stime = (SpaceTime *)sl;
- stime->caches.first = stime->caches.last = NULL;
+ BLI_listbase_clear(&stime->caches);
}
else if (sl->spacetype == SPACE_LOGIC) {
SpaceLogic *slogic = (SpaceLogic *)sl;
@@ -6508,7 +6507,7 @@ static bool direct_link_screen(FileData *fd, bScreen *sc)
}
}
- sa->actionzones.first = sa->actionzones.last = NULL;
+ BLI_listbase_clear(&sa->actionzones);
sa->v1 = newdataadr(fd, sa->v1);
sa->v2 = newdataadr(fd, sa->v2);
@@ -6764,8 +6763,8 @@ static void direct_link_movieclip(FileData *fd, MovieClip *clip)
clip->tracking.stabilization.rot_track = newdataadr(fd, clip->tracking.stabilization.rot_track);
clip->tracking.dopesheet.ok = 0;
- clip->tracking.dopesheet.channels.first = clip->tracking.dopesheet.channels.last = NULL;
- clip->tracking.dopesheet.coverage_segments.first = clip->tracking.dopesheet.coverage_segments.last = NULL;
+ BLI_listbase_clear(&clip->tracking.dopesheet.channels);
+ BLI_listbase_clear(&clip->tracking.dopesheet.coverage_segments);
link_list(fd, &tracking->objects);
diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c
index 62e3955ca60..c276bd0876c 100644
--- a/source/blender/blenloader/intern/versioning_250.c
+++ b/source/blender/blenloader/intern/versioning_250.c
@@ -934,7 +934,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
//BKE_ptcache_ids_from_object(&pidlist, ob);
//for (pid = pidlist.first; pid; pid = pid->next) {
- // if (pid->ptcaches->first == NULL)
+ // if (BLI_listbase_is_empty(pid->ptcaches))
// pid->ptcaches->first = pid->ptcaches->last = pid->cache;
//}
diff --git a/source/blender/blenloader/intern/versioning_260.c b/source/blender/blenloader/intern/versioning_260.c
index 8c9c3c86245..af6355d7009 100644
--- a/source/blender/blenloader/intern/versioning_260.c
+++ b/source/blender/blenloader/intern/versioning_260.c
@@ -248,7 +248,7 @@ static void do_versions_nodetree_multi_file_output_format_2_62_1(Scene *sce, bNo
/* ugly, need to remove the old inputs list to avoid bad pointer checks when adding new sockets.
* sock->storage is expected to contain path info in ntreeCompositOutputFileAddSocket.
*/
- node->inputs.first = node->inputs.last = NULL;
+ BLI_listbase_clear(&node->inputs);
node->storage = nimf;
@@ -921,7 +921,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *main)
if (!tracking->settings.object_distance)
tracking->settings.object_distance = 1.0f;
- if (tracking->objects.first == NULL)
+ if (BLI_listbase_is_empty(&tracking->objects))
BKE_tracking_object_add(tracking, "Camera");
while (tracking_object) {
diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c
index cb3053ccef4..0283d9b04fb 100644
--- a/source/blender/blenloader/intern/versioning_legacy.c
+++ b/source/blender/blenloader/intern/versioning_legacy.c
@@ -2210,8 +2210,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main)
sce->r.yparts = 4;
/* adds default layer */
- if (sce->r.layers.first == NULL)
+ if (BLI_listbase_is_empty(&sce->r.layers)) {
BKE_scene_add_render_layer(sce, NULL);
+ }
else {
SceneRenderLayer *srl;
/* new layer flag for sky, was default for solid */
diff --git a/source/blender/bmesh/intern/bmesh_edgeloop.c b/source/blender/bmesh/intern/bmesh_edgeloop.c
index 4724552e4c9..4c91f22759b 100644
--- a/source/blender/bmesh/intern/bmesh_edgeloop.c
+++ b/source/blender/bmesh/intern/bmesh_edgeloop.c
@@ -252,7 +252,7 @@ static bool bm_loop_path_build_step(BLI_mempool *vs_pool, ListBase *lb, const in
/* lb is now full of free'd items, overwrite */
*lb = lb_tmp;
- return (lb->first != NULL);
+ return (BLI_listbase_is_empty(lb) == false);
}
bool BM_mesh_edgeloops_find_path(BMesh *bm, ListBase *r_eloops,
diff --git a/source/blender/bmesh/intern/bmesh_marking.c b/source/blender/bmesh/intern/bmesh_marking.c
index 2f05d901d27..77505242002 100644
--- a/source/blender/bmesh/intern/bmesh_marking.c
+++ b/source/blender/bmesh/intern/bmesh_marking.c
@@ -874,7 +874,6 @@ void _bm_select_history_store_after(BMesh *bm, BMEditSelection *ese_ref, BMHeade
void BM_select_history_clear(BMesh *bm)
{
BLI_freelistN(&bm->selected);
- bm->selected.first = bm->selected.last = NULL;
}
diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c
index 3dca80ca38a..4dba28ab035 100644
--- a/source/blender/bmesh/intern/bmesh_operators.c
+++ b/source/blender/bmesh/intern/bmesh_operators.c
@@ -1498,7 +1498,7 @@ void BMO_error_raise(BMesh *bm, BMOperator *owner, int errcode, const char *msg)
bool BMO_error_occurred(BMesh *bm)
{
- return bm->errorstack.first != NULL;
+ return (BLI_listbase_is_empty(&bm->errorstack) == false);
}
/* returns error code or 0 if no error */
diff --git a/source/blender/bmesh/intern/bmesh_walkers.c b/source/blender/bmesh/intern/bmesh_walkers.c
index af901b3359c..acb97d328cc 100644
--- a/source/blender/bmesh/intern/bmesh_walkers.c
+++ b/source/blender/bmesh/intern/bmesh_walkers.c
@@ -116,7 +116,7 @@ void BMW_init(BMWalker *walker, BMesh *bm, int type,
}
walker->worklist = BLI_mempool_create(walker->structsize, 100, 100, BLI_MEMPOOL_SYSMALLOC);
- walker->states.first = walker->states.last = NULL;
+ BLI_listbase_clear(&walker->states);
}
/**
diff --git a/source/blender/bmesh/operators/bmo_connect_pair.c b/source/blender/bmesh/operators/bmo_connect_pair.c
index 0bc29c56256..1b78a6b1dc7 100644
--- a/source/blender/bmesh/operators/bmo_connect_pair.c
+++ b/source/blender/bmesh/operators/bmo_connect_pair.c
@@ -386,8 +386,7 @@ void bmo_connect_vert_pair_exec(BMesh *bm, BMOperator *op)
/* setup context */
{
- pc.state_lb.first = NULL;
- pc.state_lb.last = NULL;
+ BLI_listbase_clear(&pc.state_lb);
pc.link_pool = BLI_mempool_create(sizeof(PathLink), 1, 512, BLI_MEMPOOL_SYSMALLOC);
}
@@ -486,7 +485,7 @@ void bmo_connect_vert_pair_exec(BMesh *bm, BMOperator *op)
}
}
- if (pc.state_lb.first == NULL) {
+ if (BLI_listbase_is_empty(&pc.state_lb)) {
found_all = false;
}
diff --git a/source/blender/collada/ArmatureExporter.cpp b/source/blender/collada/ArmatureExporter.cpp
index 174331c4644..2e92cd9c147 100644
--- a/source/blender/collada/ArmatureExporter.cpp
+++ b/source/blender/collada/ArmatureExporter.cpp
@@ -168,7 +168,7 @@ void ArmatureExporter::add_bone_node(Bone *bone, Object *ob_arm, Scene *sce,
node.setNodeSid(node_sid);
#if 0
- if (bone->childbase.first == NULL || BLI_countlist(&(bone->childbase)) >= 2) {
+ if (BLI_listbase_is_empty(&bone->childbase) || BLI_countlist(&(bone->childbase)) >= 2) {
add_blender_leaf_bone( bone, ob_arm, node);
}
else {
diff --git a/source/blender/collada/SceneExporter.cpp b/source/blender/collada/SceneExporter.cpp
index aaf9588f918..eb2d0d33a72 100644
--- a/source/blender/collada/SceneExporter.cpp
+++ b/source/blender/collada/SceneExporter.cpp
@@ -189,7 +189,7 @@ void SceneExporter::writeNodes(Object *ob, Scene *sce)
colladaNode.end();
}
- if (ob->constraints.first != NULL ) {
+ if (BLI_listbase_is_empty(&ob->constraints) == false) {
bConstraint *con = (bConstraint *) ob->constraints.first;
while (con) {
std::string con_name(id_name(con));
diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c
index 7630754db1a..efd057d4e76 100644
--- a/source/blender/editors/animation/anim_channels_edit.c
+++ b/source/blender/editors/animation/anim_channels_edit.c
@@ -80,7 +80,7 @@ void ANIM_set_active_channel(bAnimContext *ac, void *data, short datatype, int f
/* try to build list of filtered items */
ANIM_animdata_filter(ac, &anim_data, filter, data, datatype);
- if (anim_data.first == NULL)
+ if (BLI_listbase_is_empty(&anim_data))
return;
/* only clear the 'active' flag for the channels of the same type */
@@ -550,7 +550,7 @@ void ANIM_fcurve_delete_from_animdata(bAnimContext *ac, AnimData *adt, FCurve *f
/* if group has no more channels, remove it too,
* otherwise can have many dangling groups [#33541]
*/
- if (agrp->channels.first == NULL) {
+ if (BLI_listbase_is_empty(&agrp->channels)) {
BLI_freelinkN(&act->groups, agrp);
}
}
@@ -565,7 +565,7 @@ void ANIM_fcurve_delete_from_animdata(bAnimContext *ac, AnimData *adt, FCurve *f
* channel list that are empty, and linger around long after the data they
* are for has disappeared (and probably won't come back).
*/
- if ((act->curves.first == NULL) && (adt->flag & ADT_NLA_EDIT_ON) == 0) {
+ if (BLI_listbase_is_empty(&act->curves) && (adt->flag & ADT_NLA_EDIT_ON) == 0) {
id_us_min(&act->id);
adt->action = NULL;
}
@@ -844,7 +844,7 @@ static void rearrange_animchannel_flatten_islands(ListBase *islands, ListBase *s
tReorderChannelIsland *island, *isn = NULL;
/* make sure srcList is empty now */
- BLI_assert(srcList->first == NULL);
+ BLI_assert(BLI_listbase_is_empty(srcList));
/* go through merging islands */
for (island = islands->first; island; island = isn) {
@@ -866,7 +866,7 @@ static bool rearrange_animchannel_islands(ListBase *list, AnimChanRearrangeFp re
short done = FALSE;
/* don't waste effort on an empty list */
- if (list->first == NULL)
+ if (BLI_listbase_is_empty(list))
return 0;
/* group channels into islands */
@@ -1221,7 +1221,7 @@ static void animchannels_group_channels(bAnimContext *ac, bAnimListElem *adt_ref
/* remove F-Curve from group, then group too if it is now empty */
action_groups_remove_channel(act, fcu);
- if ((grp) && (grp->channels.first == NULL)) {
+ if ((grp) && BLI_listbase_is_empty(&grp->channels)) {
BLI_freelinkN(&act->groups, grp);
}
@@ -1326,7 +1326,7 @@ static int animchannels_ungroup_exec(bContext *C, wmOperator *UNUSED(op))
BLI_addtail(&act->curves, fcu);
/* delete group if it is now empty */
- if (agrp->channels.first == NULL) {
+ if (BLI_listbase_is_empty(&agrp->channels)) {
BLI_freelinkN(&act->groups, agrp);
}
}
diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c
index 3744e50db34..9d54d938cc7 100644
--- a/source/blender/editors/animation/anim_filter.c
+++ b/source/blender/editors/animation/anim_filter.c
@@ -1175,7 +1175,7 @@ static size_t animfilter_act_group(bAnimContext *ac, ListBase *anim_data, bDopeS
/* now add the list of collected channels */
BLI_movelisttolist(anim_data, &tmp_data);
- BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL));
+ BLI_assert(BLI_listbase_is_empty(&tmp_data));
items += tmp_items;
}
@@ -1429,7 +1429,7 @@ static size_t animdata_filter_gpencil(ListBase *anim_data, void *UNUSED(data), i
/* now add the list of collected channels */
BLI_movelisttolist(anim_data, &tmp_data);
- BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL));
+ BLI_assert(BLI_listbase_is_empty(&tmp_data));
items += tmp_items;
}
}
@@ -1496,7 +1496,7 @@ static size_t animdata_filter_mask(ListBase *anim_data, void *UNUSED(data), int
/* now add the list of collected channels */
BLI_movelisttolist(anim_data, &tmp_data);
- BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL));
+ BLI_assert(BLI_listbase_is_empty(&tmp_data));
items += tmp_items;
}
}
@@ -1532,7 +1532,7 @@ static size_t animdata_filter_ds_nodetree_group(bAnimContext *ac, ListBase *anim
/* now add the list of collected channels */
BLI_movelisttolist(anim_data, &tmp_data);
- BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL));
+ BLI_assert(BLI_listbase_is_empty(&tmp_data));
items += tmp_items;
}
@@ -1614,7 +1614,7 @@ static size_t animdata_filter_ds_linestyle(bAnimContext *ac, ListBase *anim_data
/* now add the list of collected channels */
BLI_movelisttolist(anim_data, &tmp_data);
- BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL));
+ BLI_assert(BLI_listbase_is_empty(&tmp_data));
items += tmp_items;
}
}
@@ -1659,7 +1659,7 @@ static size_t animdata_filter_ds_texture(bAnimContext *ac, ListBase *anim_data,
/* now add the list of collected channels */
BLI_movelisttolist(anim_data, &tmp_data);
- BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL));
+ BLI_assert(BLI_listbase_is_empty(&tmp_data));
items += tmp_items;
}
@@ -1757,7 +1757,7 @@ static size_t animdata_filter_ds_material(bAnimContext *ac, ListBase *anim_data,
/* now add the list of collected channels */
BLI_movelisttolist(anim_data, &tmp_data);
- BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL));
+ BLI_assert(BLI_listbase_is_empty(&tmp_data));
items += tmp_items;
}
@@ -1877,7 +1877,7 @@ static size_t animdata_filter_ds_modifiers(bAnimContext *ac, ListBase *anim_data
if (afm.items) {
/* now add the list of collected channels */
BLI_movelisttolist(anim_data, &afm.tmp_data);
- BLI_assert((afm.tmp_data.first == afm.tmp_data.last) && (afm.tmp_data.first == NULL));
+ BLI_assert(BLI_listbase_is_empty(&afm.tmp_data));
items += afm.items;
}
@@ -1920,7 +1920,7 @@ static size_t animdata_filter_ds_particles(bAnimContext *ac, ListBase *anim_data
/* now add the list of collected channels */
BLI_movelisttolist(anim_data, &tmp_data);
- BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL));
+ BLI_assert(BLI_listbase_is_empty(&tmp_data));
items += tmp_items;
}
}
@@ -2068,7 +2068,7 @@ static size_t animdata_filter_ds_obdata(bAnimContext *ac, ListBase *anim_data, b
/* now add the list of collected channels */
BLI_movelisttolist(anim_data, &tmp_data);
- BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL));
+ BLI_assert(BLI_listbase_is_empty(&tmp_data));
items += tmp_items;
}
@@ -2102,7 +2102,7 @@ static size_t animdata_filter_ds_keyanim(bAnimContext *ac, ListBase *anim_data,
/* now add the list of collected channels */
BLI_movelisttolist(anim_data, &tmp_data);
- BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL));
+ BLI_assert(BLI_listbase_is_empty(&tmp_data));
items += tmp_items;
}
@@ -2158,7 +2158,7 @@ static size_t animdata_filter_ds_obanim(bAnimContext *ac, ListBase *anim_data, b
/* now add the list of collected channels */
BLI_movelisttolist(anim_data, &tmp_data);
- BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL));
+ BLI_assert(BLI_listbase_is_empty(&tmp_data));
items += tmp_items;
}
@@ -2228,7 +2228,7 @@ static size_t animdata_filter_dopesheet_ob(bAnimContext *ac, ListBase *anim_data
/* now add the list of collected channels */
BLI_movelisttolist(anim_data, &tmp_data);
- BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL));
+ BLI_assert(BLI_listbase_is_empty(&tmp_data));
items += tmp_items;
}
@@ -2270,7 +2270,7 @@ static size_t animdata_filter_ds_world(bAnimContext *ac, ListBase *anim_data, bD
/* now add the list of collected channels */
BLI_movelisttolist(anim_data, &tmp_data);
- BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL));
+ BLI_assert(BLI_listbase_is_empty(&tmp_data));
items += tmp_items;
}
@@ -2324,7 +2324,7 @@ static size_t animdata_filter_ds_scene(bAnimContext *ac, ListBase *anim_data, bD
/* now add the list of collected channels */
BLI_movelisttolist(anim_data, &tmp_data);
- BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL));
+ BLI_assert(BLI_listbase_is_empty(&tmp_data));
items += tmp_items;
}
@@ -2381,7 +2381,7 @@ static size_t animdata_filter_dopesheet_scene(bAnimContext *ac, ListBase *anim_d
/* now add the list of collected channels */
BLI_movelisttolist(anim_data, &tmp_data);
- BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL));
+ BLI_assert(BLI_listbase_is_empty(&tmp_data));
items += tmp_items;
}
diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c
index 0ead68c4d4a..6a359b0e6d0 100644
--- a/source/blender/editors/animation/keyframes_general.c
+++ b/source/blender/editors/animation/keyframes_general.c
@@ -505,7 +505,7 @@ void free_anim_copybuf(void)
}
/* restore initial state */
- animcopybuf.first = animcopybuf.last = NULL;
+ BLI_listbase_clear(&animcopybuf);
animcopy_firstframe = 999999999.0f;
animcopy_lastframe = -999999999.0f;
}
@@ -774,19 +774,19 @@ short paste_animedit_keys(bAnimContext *ac, ListBase *anim_data,
const Scene *scene = (ac->scene);
- const short from_single = (animcopybuf.first == animcopybuf.last);
- const short to_simple = (anim_data->first == anim_data->last);
+ const bool from_single = BLI_listbase_is_single(&animcopybuf);
+ const bool to_simple = BLI_listbase_is_single(anim_data);
float offset = 0.0f;
int pass;
/* check if buffer is empty */
- if (animcopybuf.first == NULL) {
+ if (BLI_listbase_is_empty(&animcopybuf)) {
BKE_report(ac->reports, RPT_ERROR, "No animation data in buffer to paste");
return -1;
}
- if (anim_data->first == NULL) {
+ if (BLI_listbase_is_empty(anim_data)) {
BKE_report(ac->reports, RPT_ERROR, "No selected F-Curves to paste into");
return -1;
}
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c
index a69403b085f..41f39c1d33a 100644
--- a/source/blender/editors/animation/keyframing.c
+++ b/source/blender/editors/animation/keyframing.c
@@ -183,7 +183,7 @@ FCurve *verify_fcurve(bAction *act, const char group[], PointerRNA *ptr,
fcu = MEM_callocN(sizeof(FCurve), "FCurve");
fcu->flag = (FCURVE_VISIBLE | FCURVE_SELECTED);
- if (act->curves.first == NULL)
+ if (BLI_listbase_is_empty(&act->curves))
fcu->flag |= FCURVE_ACTIVE; /* first one added active */
/* store path - make copy, and store that */
diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c
index b0b1ae3b0c9..74bd4960838 100644
--- a/source/blender/editors/animation/keyingsets.c
+++ b/source/blender/editors/animation/keyingsets.c
@@ -892,7 +892,7 @@ short ANIM_validate_keyingset(bContext *C, ListBase *dsources, KeyingSet *ks)
/* if we don't have any paths now, then this still qualifies as invalid context */
// FIXME: we need some error conditions (to be retrieved from the iterator why this failed!)
- if (ks->paths.first == NULL)
+ if (BLI_listbase_is_empty(&ks->paths))
return MODIFYKEY_INVALID_CONTEXT;
}
else {
diff --git a/source/blender/editors/armature/armature_edit.c b/source/blender/editors/armature/armature_edit.c
index 1819492c346..db57e762848 100644
--- a/source/blender/editors/armature/armature_edit.c
+++ b/source/blender/editors/armature/armature_edit.c
@@ -808,7 +808,7 @@ static int armature_merge_exec(bContext *C, wmOperator *op)
/* get chains (ends on chains) */
chains_find_tips(arm->edbo, &chains);
- if (chains.first == NULL) return OPERATOR_CANCELLED;
+ if (BLI_listbase_is_empty(&chains)) return OPERATOR_CANCELLED;
/* each 'chain' is the last bone in the chain (with no children) */
for (chain = chains.first; chain; chain = nchain) {
@@ -916,7 +916,7 @@ static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op))
/* get chains of bones (ends on chains) */
chains_find_tips(arm->edbo, &chains);
- if (chains.first == NULL) return OPERATOR_CANCELLED;
+ if (BLI_listbase_is_empty(&chains)) return OPERATOR_CANCELLED;
/* ensure that mirror bones will also be operated on */
armature_tag_select_mirrored(arm);
diff --git a/source/blender/editors/armature/armature_utils.c b/source/blender/editors/armature/armature_utils.c
index 7c7027641d7..52e3285d240 100644
--- a/source/blender/editors/armature/armature_utils.c
+++ b/source/blender/editors/armature/armature_utils.c
@@ -655,8 +655,7 @@ static void ED_armature_ebone_listbase_free(ListBase *lb)
MEM_freeN(ebone);
}
- lb->first = NULL;
- lb->last = NULL;
+ BLI_listbase_clear(lb);
}
static void ED_armature_ebone_listbase_copy(ListBase *lb_dst, ListBase *lb_src)
@@ -664,7 +663,7 @@ static void ED_armature_ebone_listbase_copy(ListBase *lb_dst, ListBase *lb_src)
EditBone *ebone_src;
EditBone *ebone_dst;
- BLI_assert(lb_dst->first == NULL);
+ BLI_assert(BLI_listbase_is_empty(lb_dst));
for (ebone_src = lb_src->first; ebone_src; ebone_src = ebone_src->next) {
ebone_dst = MEM_dupallocN(ebone_src);
diff --git a/source/blender/editors/armature/editarmature_retarget.c b/source/blender/editors/armature/editarmature_retarget.c
index 4ea564b46ce..a0411f246c8 100644
--- a/source/blender/editors/armature/editarmature_retarget.c
+++ b/source/blender/editors/armature/editarmature_retarget.c
@@ -944,7 +944,7 @@ static void RIG_joinArcs(RigGraph *rg, RigNode *node, RigArc *joined_arc1, RigAr
joined_arc1->tail = joined_arc2->tail;
- joined_arc2->edges.first = joined_arc2->edges.last = NULL;
+ BLI_listbase_clear(&joined_arc2->edges);
BLI_removeArc((BGraph *)rg, (BArc *)joined_arc2);
@@ -2593,7 +2593,7 @@ void BIF_retargetArc(bContext *C, ReebArc *earc, RigGraph *template_rigg)
template_rigg = armatureSelectedToGraph(C, ob, ob->data);
}
- if (template_rigg->arcs.first == NULL) {
+ if (BLI_listbase_is_empty(&template_rigg->arcs)) {
// XXX
// error("No Template and no deforming bones selected");
return;
diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c
index a1ec0b595b0..68141fb85f1 100644
--- a/source/blender/editors/armature/editarmature_sketch.c
+++ b/source/blender/editors/armature/editarmature_sketch.c
@@ -979,7 +979,7 @@ static int sk_getStrokeSnapPoint(bContext *C, SK_Point *pt, SK_Sketch *sketch, S
float mvalf[2];
BLI_freelistN(&sketch->depth_peels);
- sketch->depth_peels.first = sketch->depth_peels.last = NULL;
+ BLI_listbase_clear(&sketch->depth_peels);
mvalf[0] = dd->mval[0];
mvalf[1] = dd->mval[1];
@@ -1915,8 +1915,8 @@ void sk_applyConvertGesture(bContext *C, SK_Gesture *UNUSED(gest), SK_Sketch *sk
static void sk_initGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch)
{
- gest->intersections.first = gest->intersections.last = NULL;
- gest->self_intersections.first = gest->self_intersections.last = NULL;
+ BLI_listbase_clear(&gest->intersections);
+ BLI_listbase_clear(&gest->self_intersections);
gest->segments = sk_createStroke();
gest->stk = sketch->gesture;
@@ -2093,8 +2093,7 @@ static void sk_drawSketch(Scene *scene, View3D *UNUSED(v3d), SK_Sketch *sketch,
}
#if 0
- if (sketch->depth_peels.first != NULL)
- {
+ if (BLI_listbase_is_empty(&sketch->depth_peels) == false) {
float colors[8][3] = {
{1, 0, 0},
{0, 1, 0},
diff --git a/source/blender/editors/armature/pose_group.c b/source/blender/editors/armature/pose_group.c
index 99f54de134a..d2d48fce8e6 100644
--- a/source/blender/editors/armature/pose_group.c
+++ b/source/blender/editors/armature/pose_group.c
@@ -399,7 +399,7 @@ static int group_sort_exec(bContext *C, wmOperator *UNUSED(op))
qsort(agrp_array, agrp_count, sizeof(tSortActionGroup), compare_agroup);
/* create sorted bone group list from sorted array */
- pose->agroups.first = pose->agroups.last = NULL;
+ BLI_listbase_clear(&pose->agroups);
for (i = 0; i < agrp_count; i++) {
BLI_addtail(&pose->agroups, agrp_array[i].agrp);
}
diff --git a/source/blender/editors/armature/pose_lib.c b/source/blender/editors/armature/pose_lib.c
index 7a825b3805c..f77a3da06fb 100644
--- a/source/blender/editors/armature/pose_lib.c
+++ b/source/blender/editors/armature/pose_lib.c
@@ -1069,7 +1069,7 @@ static void poselib_preview_get_next(tPoseLib_PreviewData *pld, int step)
}
/* check if any matches */
- if (pld->searchp.first == NULL) {
+ if (BLI_listbase_is_empty(&pld->searchp)) {
pld->marker = NULL;
return;
}
diff --git a/source/blender/editors/armature/pose_utils.c b/source/blender/editors/armature/pose_utils.c
index 014a64170db..380a3fffc6d 100644
--- a/source/blender/editors/armature/pose_utils.c
+++ b/source/blender/editors/armature/pose_utils.c
@@ -129,7 +129,7 @@ void poseAnim_mapping_get(bContext *C, ListBase *pfLinks, Object *ob, bAction *a
/* if no PoseChannels were found, try a second pass, doing visible ones instead
* i.e. if nothing selected, do whole pose
*/
- if (pfLinks->first == NULL) {
+ if (BLI_listbase_is_empty(pfLinks)) {
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones)
{
fcurves_to_pchan_links_get(pfLinks, ob, act, pchan);
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index 3c32f2a9eea..159fbb072f6 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -1380,7 +1380,7 @@ static int separate_exec(bContext *C, wmOperator *op)
/* 1. duplicate geometry and check for valid selection for separate */
adduplicateflagNurb(oldob, &newnurb, SELECT, true);
- if (newnurb.first == NULL) {
+ if (BLI_listbase_is_empty(&newnurb)) {
WM_cursor_wait(0);
BKE_report(op->reports, RPT_ERROR, "Cannot separate current selection");
return OPERATOR_CANCELLED;
@@ -1444,7 +1444,7 @@ static int curve_split_exec(bContext *C, wmOperator *op)
adduplicateflagNurb(obedit, &newnurb, SELECT, true);
- if (newnurb.first != NULL) {
+ if (BLI_listbase_is_empty(&newnurb) == false) {
curve_delete_segments(obedit, true);
BLI_movelisttolist(editnurb, &newnurb);
@@ -2245,7 +2245,7 @@ static void adduplicateflagNurb(Object *obedit, ListBase *newnurb,
nu = nu->prev;
}
- if (newnurb->first != NULL) {
+ if (BLI_listbase_is_empty(newnurb) == false) {
cu->actnu = cu->actvert = CU_ACT_NONE;
for (nu = newnurb->first; nu; nu = nu->next) {
@@ -5915,7 +5915,7 @@ static int duplicate_exec(bContext *C, wmOperator *op)
adduplicateflagNurb(obedit, &newnurb, SELECT, false);
- if (newnurb.first != NULL) {
+ if (BLI_listbase_is_empty(&newnurb) == false) {
BLI_movelisttolist(object_editcurve_get(obedit), &newnurb);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
}
@@ -6511,7 +6511,7 @@ int join_curve_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- tempbase.first = tempbase.last = NULL;
+ BLI_listbase_clear(&tempbase);
/* trasnform all selected curves inverse in obact */
invert_m4_m4(imat, ob->obmat);
diff --git a/source/blender/editors/gpencil/editaction_gpencil.c b/source/blender/editors/gpencil/editaction_gpencil.c
index 9b7d691f081..8fcbee6f758 100644
--- a/source/blender/editors/gpencil/editaction_gpencil.c
+++ b/source/blender/editors/gpencil/editaction_gpencil.c
@@ -275,7 +275,7 @@ void free_gpcopybuf()
{
free_gpencil_layers(&gpcopybuf);
- gpcopybuf.first = gpcopybuf.last = NULL;
+ BLI_listbase_clear(&gpcopybuf);
gpcopy_firstframe = 999999999;
}
@@ -311,7 +311,7 @@ void copy_gpdata()
gpls = (bGPDlayer *)ale->data;
gpln = MEM_callocN(sizeof(bGPDlayer), "GPCopyPasteLayer");
- gpln->frames.first = gpln->frames.last = NULL;
+ BLI_listbase_clear(&gpln->frames);
BLI_strncpy(gpln->info, gpls->info, sizeof(gpln->info));
BLI_addtail(&gpcopybuf, gpln);
@@ -449,7 +449,7 @@ void paste_gpdata(Scene *scene)
}
/* if no strokes (i.e. new frame) added, free gpf */
- if (gpf->strokes.first == NULL)
+ if (BLI_listbase_is_empty(&gpf->strokes))
gpencil_layer_delframe(gpld, gpf);
}
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index a5376741ffd..94400682f9e 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -1422,7 +1422,7 @@ static void gp_layer_to_curve(bContext *C, ReportList *reports, bGPdata *gpd, bG
return;
/* only convert if there are any strokes on this layer's frame to convert */
- if (gpf->strokes.first == NULL)
+ if (BLI_listbase_is_empty(&gpf->strokes))
return;
/* initialize camera framing */
diff --git a/source/blender/editors/gpencil/gpencil_undo.c b/source/blender/editors/gpencil/gpencil_undo.c
index 7edf723022f..136e9da389d 100644
--- a/source/blender/editors/gpencil/gpencil_undo.c
+++ b/source/blender/editors/gpencil/gpencil_undo.c
@@ -63,7 +63,7 @@ static bGPundonode *cur_node = NULL;
int ED_gpencil_session_active(void)
{
- return undo_nodes.first != NULL;
+ return (BLI_listbase_is_empty(&undo_nodes) == false);
}
int ED_undo_gpencil_step(bContext *C, int step, const char *name)
@@ -100,7 +100,7 @@ int ED_undo_gpencil_step(bContext *C, int step, const char *name)
free_gpencil_layers(&gpd->layers);
/* copy layers */
- gpd->layers.first = gpd->layers.last = NULL;
+ BLI_listbase_clear(&gpd->layers);
for (gpl = new_gpd->layers.first; gpl; gpl = gpl->next) {
/* make a copy of source layer and its data */
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index f85c53c7330..db2b804363c 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -252,7 +252,7 @@ void ui_bounds_block(uiBlock *block)
uiBut *bt;
int xof;
- if (block->buttons.first == NULL) {
+ if (BLI_listbase_is_empty(&block->buttons)) {
if (block->panel) {
block->rect.xmin = 0.0; block->rect.xmax = block->panel->sizex;
block->rect.ymin = 0.0; block->rect.ymax = block->panel->sizey;
@@ -3535,7 +3535,7 @@ void uiBlockFlipOrder(uiBlock *block)
}
/* also flip order in block itself, for example for arrowkey */
- lb.first = lb.last = NULL;
+ BLI_listbase_clear(&lb);
but = block->buttons.first;
while (but) {
next = but->next;
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index cf930d635a7..b5d7bbd022a 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -542,7 +542,7 @@ static void ui_apply_but_funcs_after(bContext *C)
/* copy to avoid recursive calls */
funcs = UIAfterFuncs;
- UIAfterFuncs.first = UIAfterFuncs.last = NULL;
+ BLI_listbase_clear(&UIAfterFuncs);
for (afterf = funcs.first; afterf; afterf = after.next) {
after = *afterf; /* copy to avoid memleak on exit() */
@@ -7906,8 +7906,9 @@ static int ui_handler_region(bContext *C, const wmEvent *event, void *UNUSED(use
ar = CTX_wm_region(C);
retval = WM_UI_HANDLER_CONTINUE;
- if (ar == NULL) return retval;
- if (ar->uiblocks.first == NULL) return retval;
+ if (ar == NULL || BLI_listbase_is_empty(&ar->uiblocks)) {
+ return retval;
+ }
/* either handle events for already activated button or try to activate */
but = ui_but_find_activated(ar);
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index 729cbc23efd..d7056d898cb 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -709,7 +709,7 @@ static void init_iconfile_list(struct ListBase *list)
int totfile, i, index = 1;
const char *icondir;
- list->first = list->last = NULL;
+ BLI_listbase_clear(list);
icondir = BLI_get_folder(BLENDER_DATAFILES, "icons");
if (icondir == NULL)
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index e10baa35d0d..a2cbd0723c9 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -2703,7 +2703,7 @@ static void ui_item_estimate(uiItem *item)
for (subitem = litem->items.first; subitem; subitem = subitem->next)
ui_item_estimate(subitem);
- if (litem->items.first == NULL)
+ if (BLI_listbase_is_empty(&litem->items))
return;
if (litem->scale[0] != 0.0f || litem->scale[1] != 0.0f)
@@ -2793,7 +2793,7 @@ static void ui_item_layout(uiItem *item)
if (item->type != ITEM_BUTTON) {
uiLayout *litem = (uiLayout *)item;
- if (litem->items.first == NULL)
+ if (BLI_listbase_is_empty(&litem->items))
return;
if (litem->align)
diff --git a/source/blender/editors/mask/mask_ops.c b/source/blender/editors/mask/mask_ops.c
index aea004438f4..28f4940f236 100644
--- a/source/blender/editors/mask/mask_ops.c
+++ b/source/blender/editors/mask/mask_ops.c
@@ -1030,7 +1030,7 @@ static int delete_exec(bContext *C, wmOperator *UNUSED(op))
/* not essential but confuses users when there are keys with no data!
* assume if they delete all data from the layer they also dont care about keys */
- if (masklay->splines.first == NULL) {
+ if (BLI_listbase_is_empty(&masklay->splines)) {
BKE_mask_layer_free_shapes(masklay);
}
}
diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c
index d24fbb3900e..a167870fdf6 100644
--- a/source/blender/editors/mesh/editmesh_knife.c
+++ b/source/blender/editors/mesh/editmesh_knife.c
@@ -262,7 +262,7 @@ static ListBase *knife_empty_list(KnifeTool_OpData *kcd)
ListBase *lst;
lst = BLI_memarena_alloc(kcd->arena, sizeof(ListBase));
- lst->first = lst->last = NULL;
+ BLI_listbase_clear(lst);
return lst;
}
diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c
index 0078dd5ccaf..652095df781 100644
--- a/source/blender/editors/mesh/editmesh_select.c
+++ b/source/blender/editors/mesh/editmesh_select.c
@@ -2774,7 +2774,7 @@ static int edbm_select_ungrouped_poll(bContext *C)
if ((em->selectmode & SCE_SELECT_VERTEX) == 0) {
CTX_wm_operator_poll_msg_set(C, "Must be in vertex selection mode");
}
- else if (obedit->defbase.first == NULL || cd_dvert_offset == -1) {
+ else if (BLI_listbase_is_empty(&obedit->defbase) || cd_dvert_offset == -1) {
CTX_wm_operator_poll_msg_set(C, "No weights/vertex groups on object");
}
else {
diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c
index 32a4adb11a6..a833c530711 100644
--- a/source/blender/editors/metaball/mball_edit.c
+++ b/source/blender/editors/metaball/mball_edit.c
@@ -131,7 +131,7 @@ static int mball_select_all_exec(bContext *C, wmOperator *op)
MetaElem *ml;
int action = RNA_enum_get(op->ptr, "action");
- if (mb->editelems->first == NULL)
+ if (BLI_listbase_is_empty(mb->editelems))
return OPERATOR_CANCELLED;
if (action == SEL_TOGGLE) {
@@ -702,7 +702,6 @@ static void *editMball_to_undoMball(void *lbe, void *UNUSED(obe))
/* allocate memory for undo ListBase */
lb = MEM_callocN(sizeof(ListBase), "listbase undo");
- lb->first = lb->last = NULL;
/* copy contents of current ListBase to the undo ListBase */
ml = editelems->first;
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index 025a7358d97..d52fd657397 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -1299,7 +1299,7 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base,
ob->adt = NULL;
ob->parent = NULL;
- ob->constraints.first = ob->constraints.last = NULL;
+ BLI_listbase_clear(&ob->constraints);
ob->curve_cache = NULL;
ob->transflag &= ~OB_DUPLI;
ob->lay = base->lay;
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index c76b866bf2d..b8caf02fcd8 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -1497,7 +1497,8 @@ static EnumPropertyItem *object_mode_set_itemsf(bContext *C, PointerRNA *UNUSED(
ob = CTX_data_active_object(C);
if (ob) {
- const bool use_mode_particle_edit = (ob->particlesystem.first != NULL) || (ob->soft != NULL) ||
+ const bool use_mode_particle_edit = (BLI_listbase_is_empty(&ob->particlesystem) == false) ||
+ (ob->soft != NULL) ||
(modifiers_findByType(ob, eModifierType_Cloth) != NULL);
while (input->identifier) {
if ((input->value == OB_MODE_EDIT && OB_TYPE_SUPPORT_EDITMODE(ob->type)) ||
diff --git a/source/blender/editors/object/object_lattice.c b/source/blender/editors/object/object_lattice.c
index 2469737c76c..8d12809b0c2 100644
--- a/source/blender/editors/object/object_lattice.c
+++ b/source/blender/editors/object/object_lattice.c
@@ -523,7 +523,7 @@ static int lattice_select_ungrouped_exec(bContext *C, wmOperator *op)
BPoint *bp;
int a, tot;
- if (obedit->defbase.first == NULL || lt->dvert == NULL) {
+ if (BLI_listbase_is_empty(&obedit->defbase) || lt->dvert == NULL) {
BKE_report(op->reports, RPT_ERROR, "No weights/vertex groups on object");
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c
index cd99fd34aac..013a6c78a15 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -313,7 +313,7 @@ static bool object_modifier_remove(Main *bmain, Object *ob, ModifierData *md,
}
if (ELEM(md->type, eModifierType_Softbody, eModifierType_Cloth) &&
- ob->particlesystem.first == NULL)
+ BLI_listbase_is_empty(&ob->particlesystem))
{
ob->mode &= ~OB_MODE_PARTICLE_EDIT;
}
diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c
index 1fce3213753..a1f447fbf50 100644
--- a/source/blender/editors/object/object_select.c
+++ b/source/blender/editors/object/object_select.c
@@ -467,7 +467,7 @@ static int object_select_linked_exec(bContext *C, wmOperator *op)
changed = object_select_all_by_dup_group(C, ob);
}
else if (nr == OBJECT_SELECT_LINKED_PARTICLE) {
- if (ob->particlesystem.first == NULL)
+ if (BLI_listbase_is_empty(&ob->particlesystem))
return OPERATOR_CANCELLED;
changed = object_select_all_by_particle(C, ob);
diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c
index fa47f8f8bd9..6f2af46fa92 100644
--- a/source/blender/editors/object/object_vgroup.c
+++ b/source/blender/editors/object/object_vgroup.c
@@ -2814,7 +2814,7 @@ static void vgroup_delete_object_mode(Object *ob, bDeformGroup *dg)
ob->actdef = 1;
/* remove all dverts */
- if (ob->defbase.first == NULL) {
+ if (BLI_listbase_is_empty(&ob->defbase)) {
if (ob->type == OB_MESH) {
Mesh *me = ob->data;
CustomData_free_layer_active(&me->vdata, CD_MDEFORMVERT, me->totvert);
@@ -2963,7 +2963,7 @@ static void vgroup_delete_edit_mode(Object *ob, bDeformGroup *dg)
ob->actdef = 1;
/* remove all dverts */
- if (ob->defbase.first == NULL) {
+ if (BLI_listbase_is_empty(&ob->defbase)) {
if (ob->type == OB_MESH) {
Mesh *me = ob->data;
CustomData_free_layer_active(&me->vdata, CD_MDEFORMVERT, me->totvert);
@@ -4057,7 +4057,7 @@ static int vertex_group_transfer_weight_exec(bContext *C, wmOperator *op)
{
if (ob_act != ob_src) {
- if (ob_src->defbase.first == NULL) {
+ if (BLI_listbase_is_empty(&ob_src->defbase)) {
BKE_reportf(op->reports, RPT_WARNING,
"Skipping object '%s' it has no vertex groups", ob_src->id.name + 2);
continue;
@@ -4133,7 +4133,7 @@ static int vertex_group_transfer_weight_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED;
}
else {
- if (op->reports->list.first == NULL) {
+ if (BLI_listbase_is_empty(&op->reports->list)) {
BKE_report(op->reports, RPT_WARNING, "Failed, no other selected objects with vertex groups found");
}
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index 253a420b88a..d9ec0cf8416 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -227,7 +227,7 @@ static PTCacheEdit *pe_get_current(Scene *scene, Object *ob, int create)
BKE_ptcache_ids_from_object(&pidlist, ob, NULL, 0);
/* in the case of only one editable thing, set pset->edittype accordingly */
- if (pidlist.first && pidlist.first == pidlist.last) {
+ if (BLI_listbase_is_single(&pidlist)) {
pid = pidlist.first;
switch (pid->type) {
case PTCACHE_TYPE_PARTICLES:
@@ -4266,7 +4266,7 @@ static void PE_create_particle_edit(Scene *scene, Object *ob, PointCache *cache,
if (cache && cache->flag & PTCACHE_DISK_CACHE)
return;
- if (psys == NULL && (cache && cache->mem_cache.first == NULL))
+ if (psys == NULL && (cache && BLI_listbase_is_empty(&cache->mem_cache)))
return;
edit = (psys) ? psys->edit : cache->edit;
@@ -4285,7 +4285,7 @@ static void PE_create_particle_edit(Scene *scene, Object *ob, PointCache *cache,
psys->free_edit= PE_free_ptcache_edit;
edit->pathcache = NULL;
- edit->pathcachebufs.first = edit->pathcachebufs.last = NULL;
+ BLI_listbase_clear(&edit->pathcachebufs);
pa = psys->particles;
LOOP_POINTS {
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index b5607b42956..1a4f7c69bd7 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -1447,7 +1447,7 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type)
break;
/* old spacedata... happened during work on 2.50, remove */
- if (sl && sl->regionbase.first == NULL) {
+ if (sl && BLI_listbase_is_empty(&sl->regionbase)) {
st->free(sl);
BLI_freelinkN(&sa->spacedata, sl);
if (slold == sl) {
@@ -1460,7 +1460,7 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type)
/* swap regions */
slold->regionbase = sa->regionbase;
sa->regionbase = sl->regionbase;
- sl->regionbase.first = sl->regionbase.last = NULL;
+ BLI_listbase_clear(&sl->regionbase);
/* put in front of list */
BLI_remlink(&sa->spacedata, sl);
@@ -1476,7 +1476,7 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type)
if (slold)
slold->regionbase = sa->regionbase;
sa->regionbase = sl->regionbase;
- sl->regionbase.first = sl->regionbase.last = NULL;
+ BLI_listbase_clear(&sl->regionbase);
}
}
diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c
index 4674a5b36a3..86e78396fdf 100644
--- a/source/blender/editors/screen/screen_edit.c
+++ b/source/blender/editors/screen/screen_edit.c
@@ -500,7 +500,7 @@ static void screen_copy(bScreen *to, bScreen *from)
BLI_duplicatelist(&to->vertbase, &from->vertbase);
BLI_duplicatelist(&to->edgebase, &from->edgebase);
BLI_duplicatelist(&to->areabase, &from->areabase);
- to->regionbase.first = to->regionbase.last = NULL;
+ BLI_listbase_clear(&to->regionbase);
s2 = to->vertbase.first;
for (s1 = from->vertbase.first; s1; s1 = s1->next, s2 = s2->next) {
@@ -520,10 +520,10 @@ static void screen_copy(bScreen *to, bScreen *from)
sa->v3 = sa->v3->newv;
sa->v4 = sa->v4->newv;
- sa->spacedata.first = sa->spacedata.last = NULL;
- sa->regionbase.first = sa->regionbase.last = NULL;
- sa->actionzones.first = sa->actionzones.last = NULL;
- sa->handlers.first = sa->handlers.last = NULL;
+ BLI_listbase_clear(&sa->spacedata);
+ BLI_listbase_clear(&sa->regionbase);
+ BLI_listbase_clear(&sa->actionzones);
+ BLI_listbase_clear(&sa->handlers);
area_copy_data(sa, saf, 0);
}
diff --git a/source/blender/editors/sculpt_paint/paint_undo.c b/source/blender/editors/sculpt_paint/paint_undo.c
index b4bd46376d3..fd8cc4df41e 100644
--- a/source/blender/editors/sculpt_paint/paint_undo.c
+++ b/source/blender/editors/sculpt_paint/paint_undo.c
@@ -191,7 +191,7 @@ static int undo_stack_step(bContext *C, UndoStack *stack, int step, const char *
}
}
else if (step == -1) {
- if ((stack->current != NULL && stack->current->next == NULL) || stack->elems.first == NULL) {
+ if ((stack->current != NULL && stack->current->next == NULL) || BLI_listbase_is_empty(&stack->elems)) {
/* pass */
}
else {
diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c
index dd414a7b2b2..e6efba4fa0c 100644
--- a/source/blender/editors/sculpt_paint/paint_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_utils.c
@@ -41,6 +41,7 @@
#include "BLI_math.h"
#include "BLI_utildefines.h"
+#include "BLI_listbase.h"
#include "BLI_rect.h"
#include "BLF_translation.h"
@@ -523,7 +524,7 @@ static int vert_select_ungrouped_exec(bContext *C, wmOperator *op)
Object *ob = CTX_data_active_object(C);
Mesh *me = ob->data;
- if ((ob->defbase.first == NULL) || (me->dvert == NULL)) {
+ if (BLI_listbase_is_empty(&ob->defbase) || (me->dvert == NULL)) {
BKE_report(op->reports, RPT_ERROR, "No weights/vertex groups on object");
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index d97eb223c3d..55296aeda18 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -2183,7 +2183,7 @@ static bool wpaint_ensure_data(bContext *C, wmOperator *op)
}
}
}
- if (ob->defbase.first == NULL) {
+ if (BLI_listbase_is_empty(&ob->defbase)) {
ED_vgroup_add(ob);
}
diff --git a/source/blender/editors/sculpt_paint/paint_vertex_proj.c b/source/blender/editors/sculpt_paint/paint_vertex_proj.c
index cf15fc3b2db..a04e15d3729 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex_proj.c
@@ -34,6 +34,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_math.h"
+#include "BLI_listbase.h"
#include "DNA_mesh_types.h"
#include "DNA_object_types.h"
@@ -175,7 +176,7 @@ static void vpaint_proj_dm_map_cosnos_update(struct VertProjHandle *vp_handle,
DerivedMesh *dm;
/* quick sanity check - we shouldn't have to run this if there are no modifiers */
- BLI_assert(ob->modifiers.first != NULL);
+ BLI_assert(BLI_listbase_is_empty(&ob->modifiers) == false);
dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX);
diff --git a/source/blender/editors/space_buttons/buttons_texture.c b/source/blender/editors/space_buttons/buttons_texture.c
index 975123f244c..eb992b65010 100644
--- a/source/blender/editors/space_buttons/buttons_texture.c
+++ b/source/blender/editors/space_buttons/buttons_texture.c
@@ -319,7 +319,7 @@ static void buttons_texture_users_from_context(ListBase *users, const bContext *
ma = give_current_material(ob, ob->actcol);
/* fill users */
- users->first = users->last = NULL;
+ BLI_listbase_clear(users);
if (ma && !limited_mode)
buttons_texture_users_find_nodetree(users, &ma->id, ma->nodetree, "Material");
diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c
index 5c8d1e84fd5..c4cbab4f230 100644
--- a/source/blender/editors/space_console/space_console.c
+++ b/source/blender/editors/space_console/space_console.c
@@ -122,8 +122,8 @@ static SpaceLink *console_duplicate(SpaceLink *sl)
/* clear or remove stuff from old */
/* TODO - duplicate?, then we also need to duplicate the py namespace */
- sconsolen->scrollback.first = sconsolen->scrollback.last = NULL;
- sconsolen->history.first = sconsolen->history.last = NULL;
+ BLI_listbase_clear(&sconsolen->scrollback);
+ BLI_listbase_clear(&sconsolen->history);
return (SpaceLink *)sconsolen;
}
@@ -216,7 +216,7 @@ static void console_main_area_draw(const bContext *C, ARegion *ar)
View2D *v2d = &ar->v2d;
View2DScrollers *scrollers;
- if (sc->scrollback.first == NULL)
+ if (BLI_listbase_is_empty(&sc->scrollback))
WM_operator_name_call((bContext *)C, "CONSOLE_OT_banner", WM_OP_EXEC_DEFAULT, NULL);
/* clear and setup matrix */
diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c
index 5e7a5690acd..ab69dc9e7b9 100644
--- a/source/blender/editors/space_graph/graph_draw.c
+++ b/source/blender/editors/space_graph/graph_draw.c
@@ -801,7 +801,7 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu)
/* No curve to modify/visualise the result?
* => We still want to show the 1-1 default...
*/
- if ((fcu->totvert == 0) && (fcu->modifiers.first == NULL)) {
+ if ((fcu->totvert == 0) && BLI_listbase_is_empty(&fcu->modifiers)) {
float t;
/* draw with thin dotted lines in style of what curve would have been */
diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c
index 68d82cd2848..93d103e11a6 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -430,7 +430,7 @@ static int graphkeys_clear_ghostcurves_exec(bContext *C, wmOperator *UNUSED(op))
sipo = (SpaceIpo *)ac.sl;
/* if no ghost curves, don't do anything */
- if (sipo->ghostCurves.first == NULL)
+ if (BLI_listbase_is_empty(&sipo->ghostCurves))
return OPERATOR_CANCELLED;
/* free ghost curves */
diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c
index 6df6b6bf0ff..a8beaadd711 100644
--- a/source/blender/editors/space_graph/graph_select.c
+++ b/source/blender/editors/space_graph/graph_select.c
@@ -1062,11 +1062,11 @@ static tNearestVertInfo *get_best_nearest_fcurve_vert(ListBase *matches)
short found = 0;
/* abort if list is empty */
- if (matches->first == NULL)
+ if (BLI_listbase_is_empty(matches))
return NULL;
/* if list only has 1 item, remove it from the list and return */
- if (matches->first == matches->last) {
+ if (BLI_listbase_is_single(matches)) {
/* need to remove from the list, otherwise it gets freed and then we can't return it */
return BLI_pophead(matches);
}
diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c
index dd302829f8e..f9539d44f2b 100644
--- a/source/blender/editors/space_image/image_buttons.c
+++ b/source/blender/editors/space_image/image_buttons.c
@@ -493,7 +493,7 @@ static void uiblock_layer_pass_arrow_buttons(uiLayout *layout, RenderResult *rr,
if (rr == NULL || iuser == NULL)
return;
- if (rr->layers.first == NULL) {
+ if (BLI_listbase_is_empty(&rr->layers)) {
uiItemL(row, IFACE_("No Layers in Render Result"), ICON_NONE);
return;
}
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index e075ea09a59..bbc24004937 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -1051,7 +1051,7 @@ static int image_open_exec(bContext *C, wmOperator *op)
if (RNA_struct_property_is_set(op->ptr, "files") && RNA_struct_property_is_set(op->ptr, "directory")) {
ListBase frames;
- frames.first = frames.last = NULL;
+ BLI_listbase_clear(&frames);
image_sequence_get_frames(op->ptr, &frames, path, sizeof(path));
frame_seq_len = image_sequence_get_len(&frames, &frame_ofs);
BLI_freelistN(&frames);
diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c
index c0e559a34cf..1f2fe6b1ecf 100644
--- a/source/blender/editors/space_nla/nla_channels.c
+++ b/source/blender/editors/space_nla/nla_channels.c
@@ -464,7 +464,7 @@ bool nlaedit_add_tracks_empty(bAnimContext *ac)
BLI_assert(adt->flag & ADT_UI_SELECTED);
/* ensure it is empty */
- if (adt->nla_tracks.first == NULL) {
+ if (BLI_listbase_is_empty(&adt->nla_tracks)) {
/* add new track to this AnimData block then */
add_nlatrack(adt, NULL);
added = true;
diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c
index 37efd52f246..f54ceeeb702 100644
--- a/source/blender/editors/space_nla/nla_edit.c
+++ b/source/blender/editors/space_nla/nla_edit.c
@@ -121,7 +121,7 @@ static int nlaedit_enable_tweakmode_exec(bContext *C, wmOperator *op)
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
/* if no blocks, popup error? */
- if (anim_data.first == NULL) {
+ if (BLI_listbase_is_empty(&anim_data)) {
BKE_report(op->reports, RPT_ERROR, "No AnimData blocks to enter tweak mode for");
return OPERATOR_CANCELLED;
}
@@ -185,7 +185,7 @@ bool nlaedit_disable_tweakmode(bAnimContext *ac)
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
/* if no blocks, popup error? */
- if (anim_data.first == NULL) {
+ if (BLI_listbase_is_empty(&anim_data)) {
BKE_report(ac->reports, RPT_ERROR, "No AnimData blocks in tweak mode to exit from");
return false;
}
@@ -1304,7 +1304,7 @@ static int nlaedit_swap_exec(bContext *C, wmOperator *op)
/* special case: if there is only 1 island (i.e. temp meta BUT NOT unselected/normal/normal-meta strips) left after this,
* and this island has two strips inside it, then we should be able to just swap these still...
*/
- if ((nlt->strips.first == nlt->strips.last) && (nlt->strips.first != NULL)) {
+ if (BLI_listbase_is_empty(&nlt->strips) == false) {
NlaStrip *mstrip = (NlaStrip *)nlt->strips.first;
if ((mstrip->flag & NLASTRIP_FLAG_TEMP_META) && (BLI_countlist(&mstrip->strips) == 2)) {
diff --git a/source/blender/editors/space_node/node_add.c b/source/blender/editors/space_node/node_add.c
index a1b1b453ee0..428495542c2 100644
--- a/source/blender/editors/space_node/node_add.c
+++ b/source/blender/editors/space_node/node_add.c
@@ -232,8 +232,9 @@ static int add_reroute_exec(bContext *C, wmOperator *op)
node_deselect_all(snode);
/* Find cut links and sort them by sockets */
- output_links.first = output_links.last = NULL;
- input_links.first = input_links.last = NULL;
+ BLI_listbase_clear(&output_links);
+ BLI_listbase_clear(&input_links);
+
for (link = ntree->links.first; link; link = link->next) {
if (nodeLinkIsHidden(link))
continue;
diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c
index 9f76a9f1eb5..114b45ed174 100644
--- a/source/blender/editors/space_node/node_edit.c
+++ b/source/blender/editors/space_node/node_edit.c
@@ -2002,7 +2002,7 @@ static int node_clipboard_paste_exec(bContext *C, wmOperator *op)
clipboard_nodes_lb = BKE_node_clipboard_get_nodes();
clipboard_links_lb = BKE_node_clipboard_get_links();
- if (clipboard_nodes_lb->first == NULL) {
+ if (BLI_listbase_is_empty(clipboard_nodes_lb)) {
BKE_report(op->reports, RPT_ERROR, "Clipboard is empty");
return OPERATOR_CANCELLED;
}
diff --git a/source/blender/editors/space_node/node_relationships.c b/source/blender/editors/space_node/node_relationships.c
index 31a9ec70660..3e1e605682f 100644
--- a/source/blender/editors/space_node/node_relationships.c
+++ b/source/blender/editors/space_node/node_relationships.c
@@ -274,7 +274,7 @@ static int node_link_viewer(const bContext *C, bNode *tonode)
bNodeSocket *sock;
/* context check */
- if (tonode == NULL || tonode->outputs.first == NULL)
+ if (tonode == NULL || BLI_listbase_is_empty(&tonode->outputs))
return OPERATOR_CANCELLED;
if (ELEM(tonode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER))
return OPERATOR_CANCELLED;
@@ -1209,7 +1209,7 @@ static bool ed_node_link_conditions(ScrArea *sa, bool test, SpaceNode **r_snode,
return false;
/* correct node */
- if (select->inputs.first == NULL || select->outputs.first == NULL)
+ if (BLI_listbase_is_empty(&select->inputs) || BLI_listbase_is_empty(&select->outputs))
return false;
/* test node for links */
diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c
index ac0010b1d55..13a702e09c4 100644
--- a/source/blender/editors/space_node/node_templates.c
+++ b/source/blender/editors/space_node/node_templates.c
@@ -387,7 +387,7 @@ static void ui_node_sock_name(bNodeSocket *sock, char name[UI_MAX_NAME_STR])
else
BLI_strncpy(node_name, node->typeinfo->ui_name, UI_MAX_NAME_STR);
- if (node->inputs.first == NULL &&
+ if (BLI_listbase_is_empty(&node->inputs) &&
node->outputs.first != node->outputs.last)
{
BLI_snprintf(name, UI_MAX_NAME_STR, "%s | %s", IFACE_(node_name), IFACE_(sock->link->fromsock->name));
diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c
index 2fe63c4b895..b8bb196b9c6 100644
--- a/source/blender/editors/space_node/space_node.c
+++ b/source/blender/editors/space_node/space_node.c
@@ -70,7 +70,7 @@ void ED_node_tree_start(SpaceNode *snode, bNodeTree *ntree, ID *id, ID *from)
path_next = path->next;
MEM_freeN(path);
}
- snode->treepath.first = snode->treepath.last = NULL;
+ BLI_listbase_clear(&snode->treepath);
if (ntree) {
path = MEM_callocN(sizeof(bNodeTreePath), "node tree path");
@@ -558,7 +558,7 @@ static SpaceLink *node_duplicate(SpaceLink *sl)
BLI_duplicatelist(&snoden->treepath, &snode->treepath);
/* clear or remove stuff from old */
- snoden->linkdrag.first = snoden->linkdrag.last = NULL;
+ BLI_listbase_clear(&snoden->linkdrag);
/* Note: no need to set node tree user counts,
* the editor only keeps at least 1 (id_us_ensure_real),
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index b4fdb1a5828..763f06bef21 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -1422,7 +1422,7 @@ static void outliner_draw_hierarchy(SpaceOops *soops, ListBase *lb, int startx,
TreeStoreElem *tselem;
int y1, y2;
- if (lb->first == NULL) return;
+ if (BLI_listbase_is_empty(lb)) return;
y1 = y2 = *starty; /* for vertical lines between objects */
for (te = lb->first; te; te = te->next) {
diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c
index 036db3bae91..4231dc6f9f8 100644
--- a/source/blender/editors/space_outliner/outliner_tree.c
+++ b/source/blender/editors/space_outliner/outliner_tree.c
@@ -1342,7 +1342,7 @@ static void outliner_sort(SpaceOops *soops, ListBase *lb)
qsort(tear + skip, totelem - skip, sizeof(tTreeSort), treesort_alpha_ob);
}
- lb->first = lb->last = NULL;
+ BLI_listbase_clear(lb);
tp = tear;
while (totelem--) {
BLI_addtail(lb, tp->te);
@@ -1443,7 +1443,7 @@ static int outliner_filter_tree(SpaceOops *soops, ListBase *lb)
}
/* if there are still items in the list, that means that there were still some matches */
- return (lb->first != NULL);
+ return (BLI_listbase_is_empty(lb) == false);
}
static void outliner_add_library_contents(Main *mainvar, SpaceOops *soops, TreeElement *te, Library *lib)
diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c
index 3a7d001f432..1f7415a3a56 100644
--- a/source/blender/editors/space_outliner/space_outliner.c
+++ b/source/blender/editors/space_outliner/space_outliner.c
@@ -451,7 +451,7 @@ static SpaceLink *outliner_duplicate(SpaceLink *sl)
SpaceOops *soutliner = (SpaceOops *)sl;
SpaceOops *soutlinern = MEM_dupallocN(soutliner);
- soutlinern->tree.first = soutlinern->tree.last = NULL;
+ BLI_listbase_clear(&soutlinern->tree);
soutlinern->treestore = NULL;
soutlinern->treehash = NULL;
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c
index c032ecf6f8d..92d8a0ae066 100644
--- a/source/blender/editors/space_sequencer/sequencer_edit.c
+++ b/source/blender/editors/space_sequencer/sequencer_edit.c
@@ -1980,7 +1980,7 @@ static int sequencer_meta_toggle_exec(bContext *C, wmOperator *UNUSED(op))
Sequence *seq;
- if (ed->metastack.first == NULL)
+ if (BLI_listbase_is_empty(&ed->metastack))
return OPERATOR_CANCELLED;
ms = ed->metastack.last;
@@ -2114,8 +2114,7 @@ static int sequencer_meta_separate_exec(bContext *C, wmOperator *UNUSED(op))
BLI_movelisttolist(ed->seqbasep, &last_seq->seqbase);
- last_seq->seqbase.first = NULL;
- last_seq->seqbase.last = NULL;
+ BLI_listbase_clear(&last_seq->seqbase);
BLI_remlink(ed->seqbasep, last_seq);
BKE_sequence_free(scene, last_seq);
diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c
index ad761971200..09d51cf7afb 100644
--- a/source/blender/editors/space_time/space_time.c
+++ b/source/blender/editors/space_time/space_time.c
@@ -691,7 +691,7 @@ static SpaceLink *time_duplicate(SpaceLink *sl)
SpaceTime *stime = (SpaceTime *)sl;
SpaceTime *stimen = MEM_dupallocN(stime);
- stimen->caches.first = stimen->caches.last = NULL;
+ BLI_listbase_clear(&stimen->caches);
return (SpaceLink *)stimen;
}
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 5a7c6172472..8a4714eeded 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -748,7 +748,7 @@ typedef struct ViewCachedString {
void view3d_cached_text_draw_begin(void)
{
ListBase *strings = &CachedText[CachedTextLevel];
- strings->first = strings->last = NULL;
+ BLI_listbase_clear(strings);
CachedTextLevel++;
}
@@ -4068,7 +4068,7 @@ static bool drawDispList_nobackface(Scene *scene, View3D *v3d, RegionView3D *rv3
if (BKE_mball_is_basis(ob)) {
lb = &ob->curve_cache->disp;
- if (lb->first == NULL) {
+ if (BLI_listbase_is_empty(lb)) {
return true;
}
@@ -6584,7 +6584,7 @@ static void draw_object_matcap_check(View3D *v3d, Object *ob)
v3d->defmaterial = MEM_mallocN(sizeof(Material), "matcap material");
*(v3d->defmaterial) = defmaterial;
- v3d->defmaterial->gpumaterial.first = v3d->defmaterial->gpumaterial.last = NULL;
+ BLI_listbase_clear(&v3d->defmaterial->gpumaterial);
v3d->defmaterial->preview = NULL;
}
/* first time users */
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index adedbc6277a..ab867472bdd 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -2398,7 +2398,7 @@ static void gpu_update_lamps_shadows(Scene *scene, View3D *v3d)
Base *base;
Object *ob;
- shadows.first = shadows.last = NULL;
+ BLI_listbase_clear(&shadows);
/* update lamp transform and gather shadow lamps */
for (SETLOOPER(scene, sce_iter, base)) {
diff --git a/source/blender/editors/space_view3d/view3d_ruler.c b/source/blender/editors/space_view3d/view3d_ruler.c
index 6aa34baeac6..8eb9c9be40b 100644
--- a/source/blender/editors/space_view3d/view3d_ruler.c
+++ b/source/blender/editors/space_view3d/view3d_ruler.c
@@ -857,7 +857,7 @@ static int view3d_ruler_modal(bContext *C, wmOperator *op, const wmEvent *event)
if (event->ctrl ||
/* weak - but user friendly */
- (ruler_info->items.first == NULL))
+ BLI_listbase_is_empty(&ruler_info->items))
{
View3D *v3d = CTX_wm_view3d(C);
const bool use_depth = (v3d->drawtype >= OB_SOLID);
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index 150ac361291..eae4406990d 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -1348,7 +1348,7 @@ static void SaveState(bContext *C, wmWindow *win)
queue_back = win->queue;
- win->queue.first = win->queue.last = NULL;
+ BLI_listbase_clear(&win->queue);
//XXX waitcursor(1);
}
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index cedbc4658b6..e4bc3f8d45a 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -3051,11 +3051,11 @@ static void posttrans_gpd_clean(bGPdata *gpd)
}
/* error checking: it is unlikely, but may be possible to have none selected */
- if (sel_buffer.first == NULL)
+ if (BLI_listbase_is_empty(&sel_buffer))
continue;
/* if all were selected (i.e. gpl->frames is empty), then just transfer sel-buf over */
- if (gpl->frames.first == NULL) {
+ if (BLI_listbase_is_empty(&gpl->frames)) {
gpl->frames.first = sel_buffer.first;
gpl->frames.last = sel_buffer.last;
@@ -3141,11 +3141,11 @@ static void posttrans_mask_clean(Mask *mask)
}
/* error checking: it is unlikely, but may be possible to have none selected */
- if (sel_buffer.first == NULL)
+ if (BLI_listbase_is_empty(&sel_buffer))
continue;
/* if all were selected (i.e. masklay->splines_shapes is empty), then just transfer sel-buf over */
- if (masklay->splines_shapes.first == NULL) {
+ if (BLI_listbase_is_empty(&masklay->splines_shapes)) {
masklay->splines_shapes.first = sel_buffer.first;
masklay->splines_shapes.last = sel_buffer.last;
diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c
index 4499a9a03d2..e7b5add64db 100644
--- a/source/blender/editors/transform/transform_snap.c
+++ b/source/blender/editors/transform/transform_snap.c
@@ -719,7 +719,7 @@ void removeSnapPoint(TransInfo *t)
if (t->tsnap.selectedPoint) {
BLI_freelinkN(&t->tsnap.points, t->tsnap.selectedPoint);
- if (t->tsnap.points.first == NULL) {
+ if (BLI_listbase_is_empty(&t->tsnap.points)) {
t->tsnap.status &= ~MULTI_POINTS;
}
@@ -908,7 +908,7 @@ static void CalcSnapGeometry(TransInfo *t, float *UNUSED(vec))
float max_dist = FLT_MAX;
float p[3] = {0.0f, 0.0f, 0.0f};
- depth_peels.first = depth_peels.last = NULL;
+ BLI_listbase_clear(&depth_peels);
peelObjectsTransForm(t, &depth_peels, mval, t->tsnap.modeSelect);
diff --git a/source/blender/ikplugin/intern/itasc_plugin.cpp b/source/blender/ikplugin/intern/itasc_plugin.cpp
index 50b538b002f..e1bc47b107f 100644
--- a/source/blender/ikplugin/intern/itasc_plugin.cpp
+++ b/source/blender/ikplugin/intern/itasc_plugin.cpp
@@ -258,14 +258,14 @@ static int initialize_chain(Object *ob, bPoseChannel *pchan_tip, bConstraint *co
if (segcount == rootbone) {
// reached this end of the chain but if the chain is overlapping with a
// previous one, we must go back up to the root of the other chain
- if ((curchan->flag & POSE_CHAIN) && curchan->iktree.first == NULL) {
+ if ((curchan->flag & POSE_CHAIN) && BLI_listbase_is_empty(&curchan->iktree)) {
rootbone++;
continue;
}
break;
}
- if (curchan->iktree.first != NULL)
+ if (BLI_listbase_is_empty(&curchan->iktree) == false)
// Oh oh, there is already a chain starting from this channel and our chain is longer...
// Should handle this by moving the previous chain up to the beginning of our chain
// For now we just stop here
@@ -273,7 +273,7 @@ static int initialize_chain(Object *ob, bPoseChannel *pchan_tip, bConstraint *co
}
if (!segcount) return 0;
// we reached a limit and still not the end of a previous chain, quit
- if ((pchan_root->flag & POSE_CHAIN) && pchan_root->iktree.first == NULL) return 0;
+ if ((pchan_root->flag & POSE_CHAIN) && BLI_listbase_is_empty(&pchan_root->iktree)) return 0;
// now that we know how many segment we have, set the flag
for (rootbone = segcount, segcount = 0, curchan = pchan_tip; segcount < rootbone; segcount++, curchan = curchan->parent) {
diff --git a/source/blender/imbuf/intern/cache.c b/source/blender/imbuf/intern/cache.c
index 4be521218f1..0c17dd21434 100644
--- a/source/blender/imbuf/intern/cache.c
+++ b/source/blender/imbuf/intern/cache.c
@@ -375,7 +375,7 @@ static unsigned int *imb_thread_cache_get_tile(ImThreadTileCache *cache, ImBuf *
}
/* not found, have to do slow lookup in global cache */
- if (cache->unused.first == NULL) {
+ if (BLI_listbase_is_empty(&cache->unused)) {
ttile = cache->tiles.last;
replacetile = ttile->global;
BLI_remlink(&cache->tiles, ttile);
diff --git a/source/blender/imbuf/intern/colormanagement.c b/source/blender/imbuf/intern/colormanagement.c
index e5884f78b75..e8ffdc83240 100644
--- a/source/blender/imbuf/intern/colormanagement.c
+++ b/source/blender/imbuf/intern/colormanagement.c
@@ -583,7 +583,7 @@ static void colormanage_free_config(void)
colorspace = colorspace_next;
}
- global_colorspaces.first = global_colorspaces.last = NULL;
+ BLI_listbase_clear(&global_colorspaces);
global_tot_colorspace = 0;
/* free displays */
@@ -604,7 +604,7 @@ static void colormanage_free_config(void)
MEM_freeN(display);
display = display_next;
}
- global_displays.first = global_displays.last = NULL;
+ BLI_listbase_clear(&global_displays);
global_tot_display = 0;
/* free views */
diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp
index 6acd5154561..401070cd799 100644
--- a/source/blender/imbuf/intern/openexr/openexr_api.cpp
+++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp
@@ -815,7 +815,7 @@ void IMB_exr_multilayer_convert(void *handle, void *base,
ExrLayer *lay;
ExrPass *pass;
- if (data->layers.first == NULL) {
+ if (BLI_listbase_is_empty(&data->layers)) {
printf("cannot convert multilayer, no layers in handle\n");
return;
}
diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c
index 9c4f88d7bf9..e8be1bd3610 100644
--- a/source/blender/makesrna/intern/rna_animation.c
+++ b/source/blender/makesrna/intern/rna_animation.c
@@ -380,7 +380,7 @@ static int rna_KeyingSet_active_ksPath_editable(PointerRNA *ptr)
KeyingSet *ks = (KeyingSet *)ptr->data;
/* only editable if there are some paths to change to */
- return (ks->paths.first != NULL);
+ return (BLI_listbase_is_empty(&ks->paths) == false);
}
static PointerRNA rna_KeyingSet_active_ksPath_get(PointerRNA *ptr)
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 813c2a3b819..0bd426b8cf0 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -1097,7 +1097,7 @@ static void rna_SpaceGraphEditor_display_mode_update(Main *UNUSED(bmain), Scene
static int rna_SpaceGraphEditor_has_ghost_curves_get(PointerRNA *ptr)
{
SpaceIpo *sipo = (SpaceIpo *)(ptr->data);
- return (sipo->ghostCurves.first != NULL);
+ return (BLI_listbase_is_empty(&sipo->ghostCurves) == false);
}
static void rna_Sequencer_view_type_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
diff --git a/source/blender/modifiers/intern/MOD_mask.c b/source/blender/modifiers/intern/MOD_mask.c
index 50788f4e4a6..f3672287d70 100644
--- a/source/blender/modifiers/intern/MOD_mask.c
+++ b/source/blender/modifiers/intern/MOD_mask.c
@@ -140,7 +140,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
* - must have verts and therefore verts assigned to vgroups to do anything useful
*/
if (!(ELEM(mmd->mode, MOD_MASK_MODE_ARM, MOD_MASK_MODE_VGROUP)) ||
- (maxVerts == 0) || (ob->defbase.first == NULL))
+ (maxVerts == 0) || BLI_listbase_is_empty(&ob->defbase))
{
return dm;
}
diff --git a/source/blender/modifiers/intern/MOD_weightvgedit.c b/source/blender/modifiers/intern/MOD_weightvgedit.c
index 0dfb0403c68..a9062c31e66 100644
--- a/source/blender/modifiers/intern/MOD_weightvgedit.c
+++ b/source/blender/modifiers/intern/MOD_weightvgedit.c
@@ -32,6 +32,7 @@
#include "BLI_ghash.h"
#include "BLI_math.h"
#include "BLI_string.h"
+#include "BLI_listbase.h"
#include "BLI_rand.h"
#include "DNA_color_types.h" /* CurveMapping. */
@@ -197,7 +198,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
/* Check if we can just return the original mesh.
* Must have verts and therefore verts assigned to vgroups to do anything useful!
*/
- if ((numVerts == 0) || (ob->defbase.first == NULL))
+ if ((numVerts == 0) || BLI_listbase_is_empty(&ob->defbase))
return dm;
/* Get vgroup idx from its name. */
diff --git a/source/blender/modifiers/intern/MOD_weightvgmix.c b/source/blender/modifiers/intern/MOD_weightvgmix.c
index 304d4c8774a..b4be0f75f81 100644
--- a/source/blender/modifiers/intern/MOD_weightvgmix.c
+++ b/source/blender/modifiers/intern/MOD_weightvgmix.c
@@ -31,6 +31,7 @@
#include "BLI_utildefines.h"
#include "BLI_math.h"
#include "BLI_string.h"
+#include "BLI_listbase.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
@@ -244,7 +245,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
/* Check if we can just return the original mesh.
* Must have verts and therefore verts assigned to vgroups to do anything useful!
*/
- if ((numVerts == 0) || (ob->defbase.first == NULL))
+ if ((numVerts == 0) || BLI_listbase_is_empty(&ob->defbase))
return dm;
/* Get vgroup idx from its name. */
diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c
index 63019770942..8115cdaa640 100644
--- a/source/blender/modifiers/intern/MOD_weightvgproximity.c
+++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c
@@ -30,6 +30,7 @@
#include "BLI_utildefines.h"
#include "BLI_ghash.h"
+#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_string.h"
#include "BLI_rand.h"
@@ -380,7 +381,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der
/* Check if we can just return the original mesh.
* Must have verts and therefore verts assigned to vgroups to do anything useful!
*/
- if ((numVerts == 0) || (ob->defbase.first == NULL))
+ if ((numVerts == 0) || BLI_listbase_is_empty(&ob->defbase))
return dm;
/* Get our target object. */
diff --git a/source/blender/nodes/composite/nodes/node_composite_image.c b/source/blender/nodes/composite/nodes/node_composite_image.c
index 04a56a9f505..f87cf9da90b 100644
--- a/source/blender/nodes/composite/nodes/node_composite_image.c
+++ b/source/blender/nodes/composite/nodes/node_composite_image.c
@@ -269,7 +269,7 @@ static void cmp_node_image_verify_outputs(bNodeTree *ntree, bNode *node)
/* store current nodes in oldsocklist, then clear socket list */
oldsocklist = node->outputs;
- node->outputs.first = node->outputs.last = NULL;
+ BLI_listbase_clear(&node->outputs);
/* XXX make callback */
cmp_node_image_create_outputs(ntree, node);
diff --git a/source/blender/nodes/intern/node_common.c b/source/blender/nodes/intern/node_common.c
index a3298de5d59..0ed6530cbaa 100644
--- a/source/blender/nodes/intern/node_common.c
+++ b/source/blender/nodes/intern/node_common.c
@@ -392,7 +392,7 @@ static void node_group_input_update(bNodeTree *ntree, bNode *node)
ListBase tmplinks;
/* find links from the extension socket and store them */
- tmplinks.first = tmplinks.last = NULL;
+ BLI_listbase_clear(&tmplinks);
for (link = ntree->links.first; link; link = link->next) {
if (nodeLinkIsHidden(link))
continue;
@@ -479,7 +479,7 @@ static void node_group_output_update(bNodeTree *ntree, bNode *node)
ListBase tmplinks;
/* find links to the extension socket and store them */
- tmplinks.first = tmplinks.last = NULL;
+ BLI_listbase_clear(&tmplinks);
for (link = ntree->links.first; link; link = link->next) {
if (nodeLinkIsHidden(link))
continue;
diff --git a/source/blender/render/intern/source/envmap.c b/source/blender/render/intern/source/envmap.c
index ac814e9e033..311ec1efc6b 100644
--- a/source/blender/render/intern/source/envmap.c
+++ b/source/blender/render/intern/source/envmap.c
@@ -149,7 +149,7 @@ static Render *envmap_render_copy(Render *re, EnvMap *env)
/* set up renderdata */
envre->r = re->r;
envre->r.mode &= ~(R_BORDER | R_PANORAMA | R_ORTHO | R_MBLUR);
- envre->r.layers.first = envre->r.layers.last = NULL;
+ BLI_listbase_clear(&envre->r.layers);
envre->r.filtertype = 0;
envre->r.tilex = envre->r.xsch / 2;
envre->r.tiley = envre->r.ysch / 2;
@@ -202,11 +202,11 @@ static void envmap_free_render_copy(Render *envre)
envre->totlamp = 0;
envre->totinstance = 0;
envre->sortedhalos = NULL;
- envre->lights.first = envre->lights.last = NULL;
- envre->objecttable.first = envre->objecttable.last = NULL;
- envre->customdata_names.first = envre->customdata_names.last = NULL;
+ BLI_listbase_clear(&envre->lights);
+ BLI_listbase_clear(&envre->objecttable);
+ BLI_listbase_clear(&envre->customdata_names);
envre->raytree = NULL;
- envre->instancetable.first = envre->instancetable.last = NULL;
+ BLI_listbase_clear(&envre->instancetable);
envre->objectinstance = NULL;
envre->qmcsamplers = NULL;
diff --git a/source/blender/render/intern/source/multires_bake.c b/source/blender/render/intern/source/multires_bake.c
index 3ae075b4936..be6d0111819 100644
--- a/source/blender/render/intern/source/multires_bake.c
+++ b/source/blender/render/intern/source/multires_bake.c
@@ -1197,7 +1197,7 @@ static void count_images(MultiresBakeRender *bkr)
DerivedMesh *dm = bkr->lores_dm;
MTFace *mtface = CustomData_get_layer(&dm->faceData, CD_MTFACE);
- bkr->image.first = bkr->image.last = NULL;
+ BLI_listbase_clear(&bkr->image);
bkr->tot_image = 0;
totface = dm->getNumTessFaces(dm);
diff --git a/source/blender/render/intern/source/render_result.c b/source/blender/render/intern/source/render_result.c
index 5e8b030c3fa..b174748a050 100644
--- a/source/blender/render/intern/source/render_result.c
+++ b/source/blender/render/intern/source/render_result.c
@@ -576,7 +576,7 @@ RenderResult *render_result_new(Render *re, rcti *partrct, int crop, int savebuf
render_layer_add_pass(rr, rl, 3, SCE_PASS_SUBSURFACE_COLOR);
}
/* sss, previewrender and envmap don't do layers, so we make a default one */
- if (rr->layers.first == NULL && !(layername && layername[0])) {
+ if (BLI_listbase_is_empty(&rr->layers) && !(layername && layername[0])) {
rl = MEM_callocN(sizeof(RenderLayer), "new render layer");
BLI_addtail(&rr->layers, rl);
diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c
index 1fb65a4782e..c3ca3ee4559 100644
--- a/source/blender/render/intern/source/rendercore.c
+++ b/source/blender/render/intern/source/rendercore.c
@@ -926,7 +926,7 @@ static void freeps(ListBase *lb)
MEM_freeN(psm->ps);
MEM_freeN(psm);
}
- lb->first= lb->last= NULL;
+ BLI_listbase_clear(lb);
}
static void addps(ListBase *lb, intptr_t *rd, int obi, int facenr, int z, int maskz, unsigned short mask)
diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c
index 4460a1167ff..3c7a7676a63 100644
--- a/source/blender/windowmanager/intern/wm.c
+++ b/source/blender/windowmanager/intern/wm.c
@@ -369,8 +369,10 @@ void WM_check(bContext *C)
wm = CTX_data_main(C)->wm.first;
CTX_wm_manager_set(C, wm);
}
- if (wm == NULL) return;
- if (wm->windows.first == NULL) return;
+
+ if (wm == NULL || BLI_listbase_is_empty(&wm->windows)) {
+ return;
+ }
if (!G.background) {
/* case: fileread */
@@ -401,8 +403,10 @@ void wm_clear_default_size(bContext *C)
wm = CTX_data_main(C)->wm.first;
CTX_wm_manager_set(C, wm);
}
- if (wm == NULL) return;
- if (wm->windows.first == NULL) return;
+
+ if (wm == NULL || BLI_listbase_is_empty(&wm->windows)) {
+ return;
+ }
for (win = wm->windows.first; win; win = win->next) {
win->sizex = 0;
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index b220954b5b9..b406f6f862f 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -2114,7 +2114,9 @@ static void wm_paintcursor_test(bContext *C, wmEvent *event)
static void wm_event_drag_test(wmWindowManager *wm, wmWindow *win, wmEvent *event)
{
- if (wm->drags.first == NULL) return;
+ if (BLI_listbase_is_empty(&wm->drags)) {
+ return;
+ }
if (event->type == MOUSEMOVE)
win->screen->do_draw_drag = TRUE;
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index 7bbf78ef089..03f717f0737 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -140,7 +140,7 @@ static void wm_window_match_init(bContext *C, ListBase *wmlist)
wmWindow *win, *active_win;
*wmlist = G.main->wm;
- G.main->wm.first = G.main->wm.last = NULL;
+ BLI_listbase_clear(&G.main->wm);
active_win = CTX_wm_window(C);
@@ -193,7 +193,7 @@ static void wm_window_match_do(bContext *C, ListBase *oldwmlist)
wmWindow *oldwin, *win;
/* cases 1 and 2 */
- if (oldwmlist->first == NULL) {
+ if (BLI_listbase_is_empty(oldwmlist)) {
if (G.main->wm.first) {
/* nothing todo */
}
@@ -205,7 +205,7 @@ static void wm_window_match_do(bContext *C, ListBase *oldwmlist)
/* cases 3 and 4 */
/* we've read file without wm..., keep current one entirely alive */
- if (G.main->wm.first == NULL) {
+ if (BLI_listbase_is_empty(&G.main->wm)) {
bScreen *screen = NULL;
/* when loading without UI, no matching needed */
@@ -244,7 +244,7 @@ static void wm_window_match_do(bContext *C, ListBase *oldwmlist)
wm->defaultconf = oldwm->defaultconf;
wm->userconf = oldwm->userconf;
- oldwm->keyconfigs.first = oldwm->keyconfigs.last = NULL;
+ BLI_listbase_clear(&oldwm->keyconfigs);
oldwm->addonconf = NULL;
oldwm->defaultconf = NULL;
oldwm->userconf = NULL;
@@ -588,7 +588,7 @@ int wm_homefile_read(bContext *C, ReportList *reports, bool from_memory, const c
if (BLI_access(startstr, R_OK) == 0) {
success = (BKE_read_file(C, startstr, NULL) != BKE_READ_FILE_FAIL);
}
- if (U.themes.first == NULL) {
+ if (BLI_listbase_is_empty(&U.themes)) {
if (G.debug & G_DEBUG)
printf("\nNote: No (valid) '%s' found, fall back to built-in default.\n\n", startstr);
success = 0;
@@ -602,7 +602,9 @@ int wm_homefile_read(bContext *C, ReportList *reports, bool from_memory, const c
if (success == 0) {
success = BKE_read_file_from_memory(C, datatoc_startup_blend, datatoc_startup_blend_size, NULL, true);
- if (wmbase.first == NULL) wm_clear_default_size(C);
+ if (BLI_listbase_is_empty(&wmbase)) {
+ wm_clear_default_size(C);
+ }
BLI_init_temporary_dir(U.tempdir);
#ifdef WITH_PYTHON_SECURITY
@@ -715,7 +717,7 @@ void wm_read_history(void)
lines = BLI_file_read_as_lines(name);
- G.recent_files.first = G.recent_files.last = NULL;
+ BLI_listbase_clear(&G.recent_files);
/* read list of recent opened files from recent-files.txt to memory */
for (l = lines, num = 0; l && (num < U.recent_files); l = l->next) {
diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c
index c13d1dca0c4..d6ceb8caf29 100644
--- a/source/blender/windowmanager/intern/wm_keymap.c
+++ b/source/blender/windowmanager/intern/wm_keymap.c
@@ -344,7 +344,7 @@ static wmKeyMap *wm_keymap_copy(wmKeyMap *keymap)
keymapn->modal_items = keymap->modal_items;
keymapn->poll = keymap->poll;
- keymapn->items.first = keymapn->items.last = NULL;
+ BLI_listbase_clear(&keymapn->items);
keymapn->flag &= ~(KEYMAP_UPDATE | KEYMAP_EXPANDED);
for (kmdi = keymap->diff_items.first; kmdi; kmdi = kmdi->next) {
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index af01cf10708..4e39394b1bc 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -3978,7 +3978,7 @@ static int radial_control_invoke(bContext *C, wmOperator *op, const wmEvent *eve
/* temporarily disable other paint cursors */
wm = CTX_wm_manager(C);
rc->orig_paintcursors = wm->paintcursors;
- wm->paintcursors.first = wm->paintcursors.last = NULL;
+ BLI_listbase_clear(&wm->paintcursors);
/* add radial control paint cursor */
rc->cursor = WM_paint_cursor_activate(wm, op->type->poll,
diff --git a/source/creator/creator.c b/source/creator/creator.c
index 82b86a2d3b0..8fdd19e007a 100644
--- a/source/creator/creator.c
+++ b/source/creator/creator.c
@@ -1262,7 +1262,7 @@ static int load_file(int UNUSED(argc), const char **argv, void *data)
Main *bmain = CTX_data_main(C);
/* special case, 2.4x files */
- if (wm == NULL && CTX_data_main(C)->wm.first == NULL) {
+ if (wm == NULL && BLI_listbase_is_empty(&bmain->wm)) {
extern void wm_add_default(bContext *C);
/* wm_add_default() needs the screen to be set. */
diff --git a/source/gameengine/Converter/BL_ArmatureObject.cpp b/source/gameengine/Converter/BL_ArmatureObject.cpp
index 7ce1c7c815a..34d706eff03 100644
--- a/source/gameengine/Converter/BL_ArmatureObject.cpp
+++ b/source/gameengine/Converter/BL_ArmatureObject.cpp
@@ -116,9 +116,9 @@ void game_copy_pose(bPose **dst, bPose *src, int copy_constraint)
// BKE_copy_constraints NULLs listb, no need to make extern for this operation.
BKE_copy_constraints(&listb, &pchan->constraints, FALSE);
pchan->constraints= listb;
- } else {
- pchan->constraints.first = NULL;
- pchan->constraints.last = NULL;
+ }
+ else {
+ BLI_listbase_clear(&pchan->constraints);
}
if (pchan->custom) {
diff --git a/source/gameengine/VideoTexture/VideoFFmpeg.cpp b/source/gameengine/VideoTexture/VideoFFmpeg.cpp
index 3bad7c92efe..44017f37d29 100644
--- a/source/gameengine/VideoTexture/VideoFFmpeg.cpp
+++ b/source/gameengine/VideoTexture/VideoFFmpeg.cpp
@@ -73,12 +73,12 @@ m_isThreaded(false), m_isStreaming(false), m_stopThread(false), m_cacheStarted(f
setFlip(true);
// construction is OK
*hRslt = S_OK;
- m_thread.first = m_thread.last = NULL;
+ BLI_listbase_clear(&m_thread);
pthread_mutex_init(&m_cacheMutex, NULL);
- m_frameCacheFree.first = m_frameCacheFree.last = NULL;
- m_frameCacheBase.first = m_frameCacheBase.last = NULL;
- m_packetCacheFree.first = m_packetCacheFree.last = NULL;
- m_packetCacheBase.first = m_packetCacheBase.last = NULL;
+ BLI_listbase_clear(&m_frameCacheFree);
+ BLI_listbase_clear(&m_frameCacheBase);
+ BLI_listbase_clear(&m_packetCacheFree);
+ BLI_listbase_clear(&m_packetCacheBase);
}
// destructor