ListBase API: add utility api funcs for clearing and checking empty
authorCampbell Barton <ideasman42@gmail.com>
Fri, 7 Feb 2014 19:07:10 +0000 (06:07 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 7 Feb 2014 19:24:05 +0000 (06:24 +1100)
146 files changed:
source/blender/blenfont/intern/blf_font.c
source/blender/blenkernel/intern/action.c
source/blender/blenkernel/intern/anim_sys.c
source/blender/blenkernel/intern/armature.c
source/blender/blenkernel/intern/blender.c
source/blender/blenkernel/intern/bpath.c
source/blender/blenkernel/intern/constraint.c
source/blender/blenkernel/intern/context.c
source/blender/blenkernel/intern/curve.c
source/blender/blenkernel/intern/deform.c
source/blender/blenkernel/intern/depsgraph.c
source/blender/blenkernel/intern/displist.c
source/blender/blenkernel/intern/fcurve.c
source/blender/blenkernel/intern/fmodifier.c
source/blender/blenkernel/intern/freestyle.c
source/blender/blenkernel/intern/gpencil.c
source/blender/blenkernel/intern/group.c
source/blender/blenkernel/intern/implicit.c
source/blender/blenkernel/intern/ipo.c
source/blender/blenkernel/intern/key.c
source/blender/blenkernel/intern/linestyle.c
source/blender/blenkernel/intern/mask.c
source/blender/blenkernel/intern/material.c
source/blender/blenkernel/intern/mball.c
source/blender/blenkernel/intern/nla.c
source/blender/blenkernel/intern/node.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/object_deform.c
source/blender/blenkernel/intern/object_dupli.c
source/blender/blenkernel/intern/particle.c
source/blender/blenkernel/intern/particle_system.c
source/blender/blenkernel/intern/pointcache.c
source/blender/blenkernel/intern/report.c
source/blender/blenkernel/intern/scene.c
source/blender/blenkernel/intern/screen.c
source/blender/blenkernel/intern/seqcache.c
source/blender/blenkernel/intern/seqmodifier.c
source/blender/blenkernel/intern/sequencer.c
source/blender/blenkernel/intern/sketch.c
source/blender/blenkernel/intern/smoke.c
source/blender/blenkernel/intern/text.c
source/blender/blenkernel/intern/tracking.c
source/blender/blenlib/BLI_listbase.h
source/blender/blenlib/intern/BLI_args.c
source/blender/blenlib/intern/BLI_mempool.c
source/blender/blenlib/intern/scanfill.c
source/blender/blenlib/intern/task.c
source/blender/blenlib/intern/threads.c
source/blender/blenloader/intern/readblenentry.c
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/versioning_250.c
source/blender/blenloader/intern/versioning_260.c
source/blender/blenloader/intern/versioning_legacy.c
source/blender/bmesh/intern/bmesh_edgeloop.c
source/blender/bmesh/intern/bmesh_marking.c
source/blender/bmesh/intern/bmesh_operators.c
source/blender/bmesh/intern/bmesh_walkers.c
source/blender/bmesh/operators/bmo_connect_pair.c
source/blender/collada/ArmatureExporter.cpp
source/blender/collada/SceneExporter.cpp
source/blender/editors/animation/anim_channels_edit.c
source/blender/editors/animation/anim_filter.c
source/blender/editors/animation/keyframes_general.c
source/blender/editors/animation/keyframing.c
source/blender/editors/animation/keyingsets.c
source/blender/editors/armature/armature_edit.c
source/blender/editors/armature/armature_utils.c
source/blender/editors/armature/editarmature_retarget.c
source/blender/editors/armature/editarmature_sketch.c
source/blender/editors/armature/pose_group.c
source/blender/editors/armature/pose_lib.c
source/blender/editors/armature/pose_utils.c
source/blender/editors/curve/editcurve.c
source/blender/editors/gpencil/editaction_gpencil.c
source/blender/editors/gpencil/gpencil_edit.c
source/blender/editors/gpencil/gpencil_undo.c
source/blender/editors/interface/interface.c
source/blender/editors/interface/interface_handlers.c
source/blender/editors/interface/interface_icons.c
source/blender/editors/interface/interface_layout.c
source/blender/editors/mask/mask_ops.c
source/blender/editors/mesh/editmesh_knife.c
source/blender/editors/mesh/editmesh_select.c
source/blender/editors/metaball/mball_edit.c
source/blender/editors/object/object_add.c
source/blender/editors/object/object_edit.c
source/blender/editors/object/object_lattice.c
source/blender/editors/object/object_modifier.c
source/blender/editors/object/object_select.c
source/blender/editors/object/object_vgroup.c
source/blender/editors/physics/particle_edit.c
source/blender/editors/screen/area.c
source/blender/editors/screen/screen_edit.c
source/blender/editors/sculpt_paint/paint_undo.c
source/blender/editors/sculpt_paint/paint_utils.c
source/blender/editors/sculpt_paint/paint_vertex.c
source/blender/editors/sculpt_paint/paint_vertex_proj.c
source/blender/editors/space_buttons/buttons_texture.c
source/blender/editors/space_console/space_console.c
source/blender/editors/space_graph/graph_draw.c
source/blender/editors/space_graph/graph_edit.c
source/blender/editors/space_graph/graph_select.c
source/blender/editors/space_image/image_buttons.c
source/blender/editors/space_image/image_ops.c
source/blender/editors/space_nla/nla_channels.c
source/blender/editors/space_nla/nla_edit.c
source/blender/editors/space_node/node_add.c
source/blender/editors/space_node/node_edit.c
source/blender/editors/space_node/node_relationships.c
source/blender/editors/space_node/node_templates.c
source/blender/editors/space_node/space_node.c
source/blender/editors/space_outliner/outliner_draw.c
source/blender/editors/space_outliner/outliner_tree.c
source/blender/editors/space_outliner/space_outliner.c
source/blender/editors/space_sequencer/sequencer_edit.c
source/blender/editors/space_time/space_time.c
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/space_view3d/view3d_draw.c
source/blender/editors/space_view3d/view3d_ruler.c
source/blender/editors/space_view3d/view3d_view.c
source/blender/editors/transform/transform_conversions.c
source/blender/editors/transform/transform_snap.c
source/blender/ikplugin/intern/itasc_plugin.cpp
source/blender/imbuf/intern/cache.c
source/blender/imbuf/intern/colormanagement.c
source/blender/imbuf/intern/openexr/openexr_api.cpp
source/blender/makesrna/intern/rna_animation.c
source/blender/makesrna/intern/rna_space.c
source/blender/modifiers/intern/MOD_mask.c
source/blender/modifiers/intern/MOD_weightvgedit.c
source/blender/modifiers/intern/MOD_weightvgmix.c
source/blender/modifiers/intern/MOD_weightvgproximity.c
source/blender/nodes/composite/nodes/node_composite_image.c
source/blender/nodes/intern/node_common.c
source/blender/render/intern/source/envmap.c
source/blender/render/intern/source/multires_bake.c
source/blender/render/intern/source/render_result.c
source/blender/render/intern/source/rendercore.c
source/blender/windowmanager/intern/wm.c
source/blender/windowmanager/intern/wm_event_system.c
source/blender/windowmanager/intern/wm_files.c
source/blender/windowmanager/intern/wm_keymap.c
source/blender/windowmanager/intern/wm_operators.c
source/creator/creator.c
source/gameengine/Converter/BL_ArmatureObject.cpp
source/gameengine/VideoTexture/VideoFFmpeg.cpp

index 846c9cca55ca47216c7680763e3cf52fa34bb227..ac0350268146972c5d4ab2a0e56f0d9b4f17180b 100644 (file)
@@ -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;
index 8967df14b24e498ac4b14d90022edf63067f55c7..3a32cad08735cb174cd4f4e5c21311defde71119 100644 (file)
@@ -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;
                }
        }
index a46b308f76be8f31eb481d7f5981dd0724177f2e..5c50b9d6bec93af2532015d5fd1a4e7b5c63ce23 100644 (file)
@@ -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");
                        
index 699e71393c8ed60b9bd70482a60983e82979f78c..caec93a6627ff52f394e2ae1ecc1593cb5c072c1 100644 (file)
@@ -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])
index 2b87a7684d285abb526eb3256599c47022ac7270..ed48bf5f3a4c91cda4737c59335e31a0764c37ea 100644 (file)
@@ -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;
 
index b7a6cf4153a4152ac66b0670fece477f77e5e04e..00fff61c6a2c132f9403f64c294371d1445b42ab 100644 (file)
@@ -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);
 }
index 2eca9f30bfb6bcbea788ec0a13333844bca7d029..c14e8dd5e16609143da051893e113f024d45f7c0 100644 (file)
@@ -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) {
index 2eb763831e41e1dcd359e2bd0b7adbf580e25d5d..a63807f4bcb68da5bbce75ac0412ca1c291962a6 100644 (file)
@@ -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;
 }
index c5979686afbf60632f771987090bc4bb0a9ba1e7..8567a57d153cd2401109385e92a52f200637a249 100644 (file)
@@ -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])
index 6ff27e50bf87ec3d85cdabb688d4d56004b625d1..82b6dded29c52408927815cbce4815c932679a49 100644 (file)
@@ -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);
index 5f4bfc8ad231ac174e67ab25a608ef5d603a20a5..af84055fb50c91e2a72d2c8e72853e8b77525e59 100644 (file)
@@ -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);
        
index ee2c42d33cdabdfaa8bba40c8dd2e350247f8446..517c83295677fc79a7eb88bec1246be74d449dbf 100644 (file)
@@ -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);
index c93181bd903eb5580556faaf28c4212a98659819..bcdb066a965e679ba10e58cb60df1ccc9c1678a1 100644 (file)
@@ -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);
index 325a26d7a16bfe3ff08b1e4ca7820e161d24bd74..6c98808f087384bc14359b76c4081877837dd14d 100644 (file)
@@ -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) {
index 3e0668ba05cc1ebedda4ea2eced8817060d0db19..f5a9ba4e241dce8473488cf57f383ab471ffa167 100644 (file)
@@ -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);
index 9bace5e1ee3e0338e2ec83108d6ddda6ed0782a8..2eed25cde0e1ab5466b335d7dcd90dc8118f743e 100644 (file)
@@ -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);
        }
index 82b6c0c04d584dd97308560adbecf5fc07470580..2a61b2e7453015e612e590a2a20a16753342185a 100644 (file)
@@ -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;
                }
index d328c90aab33b6a11ced8b3f1fbbe4aebf7e7376..08959850fb959d412eed53607ca3252d35220531 100644 (file)
@@ -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;
index 8ef3b7ef23d8829bde6b64a5399927d2225ef3ab..cf66d866c2cd1ed74c3cbef9ed1ce5612cd36188 100644 (file)
@@ -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 */
index d2080b4922c862bc877312a9b5f269d35548c9a1..93833f5c5aecef1c1789978ebeb92f0f9737b6d3 100644 (file)
@@ -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 */
index 71c917d4528549e85803751a2c14d44bb76857c5..3622174975a064d3706d5e16e44ffd228c1eff42 100644 (file)
@@ -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:
index 33e758ed754212f83ca5de4af55152e2ec482602..23c0401c1fec9f101a99df3f690a5a3ad2eafff9 100644 (file)
@@ -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 */
index 1cae95e99b3af09e0c1963eb864d901c39e1f7db..5f6331315f8ac20bb543b6a6e36dfcb2abd59feb 100644 (file)
@@ -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;
 }
 
index e5fdc449dbd4c39f742e4ae1f34f291ab4ded939..9e83d97b4509baccb5eef999b568f86c288dda9b 100644 (file)
@@ -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])
index 56796756ab59715ef10a137646772f10236f7527..06a12bdade13974c1f93b569b046bd85a164f3c2 100644 (file)
@@ -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) {
index bc616934fef9d132dacd3b41d9eacb156e6b7fbb..27a8730fe03fabf86b5c0eec80e2b0d9a46dbb2b 100644 (file)
@@ -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);
index 05365a86828790979d0656820ce38766423b5b38..6c9ffa5ab46fd2a985e7daacee1f41915bb785b7 100644 (file)
@@ -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;
 
index 77c5e57f382b1050170ca7ec7fc4eb33529e5f27..f313c098f4bcfba33ca4c0f60fcaf265b5faf649 100644 (file)
@@ -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;
        }
 
index dd9f1a268b2196b2123ed1add653f38fad1a599d..74426df58c7eda3b664dd6471fb159e97c07f3e3 100644 (file)
@@ -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))) {
index 8e256f05f71965ba6abf03bc41b6f7c914d2b482..edf902e0eb5a4942e3876b9ffcdf256dbe7c1804 100644 (file)
@@ -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);
index 6ae3e2e9d5e697c0752abd51f9135c1cdee12d50..71b9134072136f94dca0028904720c6a0f5afaf3 100644 (file)
@@ -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);
index 271160a54f09c24724c56cf973fb2f2ea34aa474..df6534946fd239af471033a0d160ae9e7b325d8b 100644 (file)
@@ -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));
index 1fd7dc14c2394f3024f789a5c4f91220d8bb9b4c..3d0713f951443d02de98ca6a248315a940c73c03 100644 (file)
@@ -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)
index 922b3860f7e744c8e956810540f467ea794b4234..09bfdbb2d951a7fe4df9b8d3d98eec4792fa83dc 100644 (file)
@@ -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;
index 5bfd5e67eb1d9204bbd54968d3ac12a68ef2260b..ab725ae04a9753c46609ca67c5b3359deb8064d5 100644 (file)
@@ -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);
index a85e70d2afced5cf5cb4a9ec5d2a598311608aea..97062f728c5586b344b6b41e938495439f1f7fcc 100644 (file)
@@ -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)
index b3b5fc1e8d08161ab5ebc89a2d620345281fcf02..27d09eeaf8f5bc8939525b463cb492fb76afde60 100644 (file)
@@ -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)
index 675c7dcea95efb68b2bc71488683a811ffb7ca5d..54cff24bb760b3cdc5561f667d0ff45622a5a297 100644 (file)
@@ -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);*/
        }
index bbd637a0a77ac63bee57eb9d53b823534c6a337e..da5dd76681d2e99fa8e4877614aa3b05dc7cdf4f 100644 (file)
@@ -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;
 }
index 8636614f7eddf4c136f83190afd93986fab63b72..6aaf2ee4df0b21850b974de950e654d5305a2f4e 100644 (file)
@@ -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();
index 829354ce6628470057cdc2784c016d43493e302c..e1396c022cb4e220b4f21c8b064f86e6cf43e032 100644 (file)
@@ -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;
index fbca675e5eef991a453ecd6c9c966efef11ac606..de20f4a8ac6496ed81f821a62ce3a7928d476cc2 100644 (file)
@@ -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.
index 0927620a2c64bd7bd6b09504f87bf1abc9e60ecd..77490929efbab9f7b0805a5248d78737cdd952a9 100644 (file)
@@ -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);
 
index fdef0d69539123d99d18ee8143d7d1022dbab6e1..fb35b55a935dfe853c6ea4c202d661dbfa379073 100644 (file)
@@ -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;
 
index 1321f006e36cd40eac941916dcd815c531099ff1..7dc43bb1494da5e3d989caea6ff8cdd4e66db674 100644 (file)
@@ -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);
index 46ab2db87f5fc20d479bd83b32cebb6422f4efa6..ae0760eb30ef283a6de1d5d749eca14a64e80f74 100644 (file)
@@ -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++) {
index 1ac4045ea4966aca0dd7de5a0443048077e86a46..8d867b9f2952bfb648bb589953e304af34b5554e 100644 (file)
@@ -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);
 
index 0b8f5dfdde58d47e89e6fbed86c836ca1c0bdf05..5d8c1af6c7f0e6855259cb311b54a11b50272a0b 100644 (file)
@@ -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);
index b03d250e868dae5b3e31a7634a502ebb757588e6..5dcf875a32b31757e00afb8a9665e881f257e92f 100644 (file)
@@ -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);
index 738b682188acb36a9a90c4299581539df2af2066..f41baf5553add4ad8cea865040de26fe70dcb75f 100644 (file)
@@ -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);
        
index 62e3955ca6042b43fbb07579c6add90363c014ed..c276bd0876c5758115f716efe7a3777b39c2152a 100644 (file)
@@ -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;
                        //}
 
index 8c9c3c86245f4be0c35b37a6fbbf1045c5b9b3ae..af6355d7009cafd8c29ade5861fa6275f678cbcd 100644 (file)
@@ -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) {
index cb3053ccef40bb816211e4d69ef16239f6c4afa9..0283d9b04fbfdb628d69c5c45f497d7aa2492a11 100644 (file)
@@ -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 */
index 4724552e4c9dc71f74273a09f75d251e786eb55e..4c91f22759bee76fa05a1a4783611f9753af7d13 100644 (file)
@@ -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,
index 2f05d901d27f6d6dc84d1821761e7499c077b21f..77505242002ea8242d50109c9ec0e94e93bb69ad 100644 (file)
@@ -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;
 }
 
 
index 3dca80ca38a9c49575b9ae0584ace4c2374375d8..4dba28ab035b82f9f2131e24ff2d3cd1b43849ca 100644 (file)
@@ -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 */
index af901b3359cf5a7d8cb9128fcd594e87fe33166c..acb97d328cca7b9146fa284d1c07aa56e3d10dfa 100644 (file)
@@ -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);
 }
 
 /**
index 0bc29c5625685db05111bcf4c0c327b3a8f78a56..1b78a6b1dc755dd7f73f0dbec4690e8cf6ad30a9 100644 (file)
@@ -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;
        }
 
index 174331c46446dbb3b14e782e3df0b18301004053..2e92cd9c147532b39cb34a62677854786c6881db 100644 (file)
@@ -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 {
index aaf9588f918f5616505ce83254f7c533e5e91d4a..eb2d0d33a72eb92b09b8525cb16b9a52b499bd31 100644 (file)
@@ -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));
index 7630754db1a415b07d1aa8cc92dad7a9d8801b35..efd057d4e76c3645aabf68fe24b29979907b6b19 100644 (file)
@@ -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);
                                }
                        }
index 3744e50db34315949917433c2bd16c8ad6b3cba8..9d54d938cc72e99a0d931f7b810c90ea2344e6cc 100644 (file)
@@ -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;
        }
        
index 0ead68c4d4aa478e75a2434b1989d7d4d326b3d3..6a359b0e6d0ddf062d4487247f5f26102d10ee47 100644 (file)
@@ -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;
        }
index a69403b085f7d1ee261770b77d17f5c1bb2a999b..41f39c1d33a186bd71f90e4cb3ad96b3df98cac3 100644 (file)
@@ -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 */
index b0b1ae3b0c95c8dfb2eeb56a380f055158f9bb46..74bd49608385f0b5c0dd9b1fcc44d5add681639b 100644 (file)
@@ -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 {
index 1819492c346ce2c55142fe6ca04e5d51c8da5c76..db57e762848202e594516b40377698fea935abab 100644 (file)
@@ -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);
index 7c7027641d77985870d6205b3004a5a0a9c2ee07..52e3285d2405d573b1f967fceead2ea05382b290 100644 (file)
@@ -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);
index 4ea564b46ce24e7cd96925a1ae5ce41f0ca44f05..a0411f246c8718beaacc1fc7d8405aa99eb64473 100644 (file)
@@ -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;
index a1ec0b595b03800950434c8070a3034df2e73906..68141fb85f158313bcca344b0e7e1c016d7708c7 100644 (file)
@@ -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},
index 99f54de134a300ba9475b430445b4c4211bf1be6..d2d48fce8e6eef8797e51c7e63afeda892a0064d 100644 (file)
@@ -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);
        }
index 7a825b3805c6a231879b22206d16d4ffad24176a..f77a3da06fb7bc6c790ebd820360925d65ee5f1e 100644 (file)
@@ -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;
                }
index 014a64170db1dba46dd1ce3dcf12360b0335e359..380a3fffc6d12b8356168314e3fd46fa28aa5428 100644 (file)
@@ -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);
index 3c32f2a9eea6fe262a9ed2e9713e72467825396c..159fbb072f6c478d5af7149be85293442e3fbe9d 100644 (file)
@@ -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);
index 9b7d691f08164de816e4c7fe1ab9fa6dae5fc586..8fcbee6f758b441bedfbda2ff90d147642b9ece1 100644 (file)
@@ -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);
                        }
                        
index a5376741ffd453766eb100328ecaa1ba876b160f..94400682f9e864692d592ec8f293284e99d34003 100644 (file)
@@ -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 */
index 7edf723022ff43f1240e18af69863de56b1a9365..136e9da389d1f73aaaa9b07b205be4a511929a44 100644 (file)
@@ -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 */
index f85c53c7330185649ff5bdc318f2cdcb3484955c..db2b804363ca33609485b28f6dec3c3c7c11a9da 100644 (file)
@@ -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;
index cf930d635a792d9251cde13eb3a53bc26d05801b..b5d7bbd022a4dbb92a06c9b16ae1e869049dd57e 100644 (file)
@@ -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);
index 729cbc23efdc7fc5ec1d0540b6164587fcae9243..d7056d898cb9731746b415680a4276608e33d593 100644 (file)
@@ -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)
index e10baa35d0d328a0cf357a33ab088a83057dbe61..a2cbd0723c9a6fb6108c03388be1ae8ce80a707b 100644 (file)
@@ -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)
index aea004438f49af944de010a1dfa90c6725db76fa..28f4940f2363c461ea121aa33c5a116dc2d10428 100644 (file)
@@ -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);
                }
        }
index d24fbb3900e51517001fba7a8b1505b0cfac0c02..a167870fdf698a5f890be9ea04be4e523d6fd9a3 100644 (file)
@@ -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;
 }
 
index 0078dd5ccafe24e06849be2ca25b0d485c18b8c0..652095df78136928dc434636859222b3ad278abc 100644 (file)
@@ -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 {
index 32a4adb11a6d6bb021c7cbabb955ef4007a46d14..a833c5307111e7f8e8cdb64dc4115e4f2a4553de 100644 (file)
@@ -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;
index 025a7358d97fd628141a4df9530d73762d31139d..d52fd657397d7135c340be597edabe278df15389 100644 (file)
@@ -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;
index c76b866bf2ddc1c6c03d696c43e8ef292d2bfd22..b8caf02fcd8c7863f5be1207d39d385927ca91bf 100644 (file)
@@ -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)) ||
index 2469737c76ce60cd3f10aec27e1495f5bd111001..8d12809b0c2b856722642b4561b629d79f33d67f 100644 (file)
@@ -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;
        }
index cd99fd34aac1fb544ad5e01452e4eaaf764577a6..013a6c78a15fc7af349b226bb8f370ad714387cb 100644 (file)
@@ -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;
        }
index 1fce32137533f2a49a712cdd1d8a0516dd03bf22..a1f447fbf50109e15f5291e55d9017d55ee9d9a3 100644 (file)
@@ -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);
index fa47f8f8bd9a95c53333b84b4e2f872db15dbdba..6f2af46fa92f48fde209100baeaa76262a22039b 100644 (file)
@@ -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");
                }
 
index 253a420b88a1b37c3da9d9a6d13516679e8a7fc7..d9ec0cf84164ccf323a259e193d9859b92da84cc 100644 (file)
@@ -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 {
index b5607b42956013acd2e18ed21d7acd74c664d4e4..1a4f7c69bd778380546f29f9c724af550a05f925 100644 (file)
@@ -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);
                        }
                }
                
index 4674a5b36a379985173933c886e3feb37b7b379b..86e78396fdf13d49d28cc6cfb98d29fb7640d860 100644 (file)
@@ -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);
        }
index b4bd46376d3900274947f023e53b083dd6375186..fd8cc4df41ef439d6f2d740233d454e1e602cb7b 100644 (file)
@@ -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 {
index dd414a7b2b21b3adc2dffbbb44173f1825d06342..e6efba4fa0c88bac0e2b4e6ed342ba4f29149392 100644 (file)
@@ -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;
        }
index d97eb223c3d1a6743aa59c3b786c1aef83c7fe7a..55296aeda18171b2fb5aac9c12135bf2053b42dc 100644 (file)
@@ -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);
        }
 
index cf15fc3b2db88345d83d06ba6018dd2a7b174559..a04e15d3729acfe9424d9c1400401c80ad8e98c1 100644 (file)
@@ -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);
 
index 975123f244cc439154b63738cd79e0ae2f1e5dab..eb992b650106be69810142f44e337785e01103af 100644 (file)
@@ -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");
index 5c8d1e84fd57aee0dc5a62204f30a9f95d0984e5..c4cbab4f2304183df57d09776b75ff20b9f5d9f8 100644 (file)
@@ -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 */
index 5e7a5690acde5fc4c65029373fa0c5d9f9e1a9c8..ab69dc9e7b99db44dc55d05bce82be68bb7e78a6 100644 (file)
@@ -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 */
index 68d82cd28486b1116bfd7b28ad76a799d75f953a..93d103e11a64c8c96d84cadb3465a566e7ad35f3 100644 (file)
@@ -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 */
index 6df6b6bf0ffd097cc65b50d5bcfdbd997f58aba9..a8beaadd71196590326ac6240f77ac67dd76b4cd 100644 (file)
@@ -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);
        }
index dd302829f8ef8bb73d24b2375fdad0b4cb948492..f9539d44f2b9e1b5236222699ee5bfec5d360b55 100644 (file)
@@ -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;
        }
index e075ea09a59f497a07125ee17cb30da8b37f9490..bbc240049371a117df3282b3a4053b9181f98c8c 100644 (file)
@@ -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);
index c0e559a34cfea5674b238e9844312d05c183cd8a..1f2fe6b1ecf2d07e821e8de9367e7e4b62a04cd0 100644 (file)
@@ -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;
index 37efd52f246124e79a6817a615ae87a0f2d47304..f54ceeeb702a4a7642fb8db5bd0df4c332817558 100644 (file)
@@ -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)) {
index a1b1b453ee0f0d973e6848007a0537b2cde6c075..428495542c26ddac622b93d7619c7703a62911bb 100644 (file)
@@ -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;
index 9f76a9f1eb52f698fe373956c388fed0652d7711..114b45ed174abf6b9e992f3e5c4abf8af7e8a3b7 100644 (file)
@@ -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;
        }
index 31a9ec706602cb48f03857cf16ab26b9208a7f39..3e1e605682f51a65de8f934ab22ad9fb5e88fee4 100644 (file)
@@ -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 */
index ac0010b1d559d76354863301a49053239b700070..13a702e09c41b0127a4b04fad9cf5bbc97affc88 100644 (file)
@@ -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));
index 2fe63c4b8959aacbc8f30b8f09f1e4db88463cf1..b8bb196b9c6638697a68fa3ee649c274d2da791e 100644 (file)
@@ -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),
index b4fdb1a5828d378b4e12858dbc0a9cc4ecab38a8..763f06bef2152fb17ace5eac3c696fa2fdd65698 100644 (file)
@@ -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) {
index 036db3bae914352b5b64413e699624b5cf8c9fb1..4231dc6f9f85a9f5a2074c1a09c909ebaaad8244 100644 (file)
@@ -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)
index 3a7d001f432331a5a7fe8bd34a939c2cc1666f7e..1f7415a3a56721409516c6dabf5256b933872e93 100644 (file)
@@ -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;
        
index c032ecf6f8d9e6ad929022b51db5530002f7be01..92d8a0ae0664d5bada3833db80609ecc5987d84a 100644 (file)
@@ -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);
index ad7619712004562464e1a19c746d1c79c2b7dc5c..09d51cf7afb9fc91da2cc70a1e66406b38bfe3d3 100644 (file)
@@ -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;
 }
index 5a7c6172472ef1e590c622188461a4d4aba5e887..8a4714eeded7d8b87fe94b243efeac919319a08b 100644 (file)
@@ -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 */
index adedbc6277a32f25c5c9275678ac94bebb8f3a4e..ab867472bdd6f73d57ce4fb2ed698f8582565191 100644 (file)
@@ -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)) {
index 6aa34baeac64c1b666669ca69b01bb376b9e2b27..8eb9c9be40b34bd6f847e80907f9ffc8b6f10d07 100644 (file)
@@ -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);
index 150ac3612918d2e67c8023169351e4c2200ebbbc..eae4406990d55d401d8c97d2afeb7406dd017eca 100644 (file)
@@ -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);
 }
index cedbc4658b66f8c35bed715916fbab94115ab4df..e4bc3f8d45ab30ddff50224d67fc4e177c2712cc 100644 (file)
@@ -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;
 
index 4499a9a03d24c0c194cb844be8bead443e9a9c6f..e7b5add64dbda2bebd29439757ff161379a2bc31 100644 (file)
@@ -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);
                        
index 50b538b002f7b878a5e248aca473d7a2f6b45d87..e1bc47b107f03d9777f10daf4602d8512bad2312 100644 (file)
@@ -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) {
index 4be521218f1a94a6f859f92a3649ba44dbfdaabd..0c17dd21434cf2bd41553cb20f4800cf2df96c6a 100644 (file)
@@ -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);
index e5884f78b75fdc7faa15aa9c063b3fe68336c7c8..e8ffdc832408989f7abcb218165a75ce2aa734ca 100644 (file)
@@ -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 */
index 6acd51545614c474b53e676df243dc39de558fa6..401070cd799a83431bcb2dca8c369376488d47a5 100644 (file)
@@ -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;
        }
index 9c4f88d7bf933d7e23935bd5c28c18d0884624e9..e8be1bd3610c97eafd59d5791906a512d91b678a 100644 (file)
@@ -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)
index 813c2a3b819b1af3877b949b9fd8a68ea8f12d47..0bd426b8cf0a1cb9f1b906f8bcc77633287435b8 100644 (file)
@@ -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)
index 50788f4e4a683c474f2fa567a827c0ae52e59760..f3672287d70d70b9d9e77ceafa6e1dc215be5cd1 100644 (file)
@@ -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;
        }
index 0dfb0403c68dc8f37a2a7afa22dea76175c1c604..a9062c31e660e87f019a0b162195dbf505baf176 100644 (file)
@@ -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. */
index 304d4c8774add2cec1a07b68db2191c499c59672..b4be0f75f81e1c018ae792f86512f86772eb5735 100644 (file)
@@ -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. */
index 630197709422502cd1236d7fc16b45940e25667f..8115cdaa640deeda0a57fbae45f4208d515284b0 100644 (file)
@@ -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. */
index 04a56a9f5052334a8280820ea95f831f92bf4b86..f87cf9da90bd679e1bea365eaec718757fb3d1a5 100644 (file)
@@ -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);
index a3298de5d5991ba098cdff679df649b29cfbaeae..0ed6530cbaa0183efcc0df26729e902cee5a9100 100644 (file)
@@ -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;
index ac814e9e03303cd488539d7fcc714de2a766b578..311ec1efc6be22dfbdaae0851704b57a470e1fc2 100644 (file)
@@ -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;
        
index 3ae075b493677b97c7e1f29b178a264bd9843dd0..be6d0111819ada43d29972eedbca31f2c246faa7 100644 (file)
@@ -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);
index 5e8b030c3fa3dd55d5a36eeb027969b238c24326..b174748a050670cb34e06c35fde82f2a564cfc86 100644 (file)
@@ -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);
                
index 1fb65a4782e0bbe326e3c1fdc106ff3c1a55c306..c3ca3ee45592f8e92577bf13607b61a8201e5aeb 100644 (file)
@@ -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)
index 4460a1167fff87e999c029a88dd1b25f03bb382b..3c7a7676a63e424e2707d4be816a6addbce1ad21 100644 (file)
@@ -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;
index b220954b5b932baa134d3e6b7ff2c4b4977983a6..b406f6f862f27c84f35f62b66ca25ce039455016 100644 (file)
@@ -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;
index 7bbf78ef089f3d57f4f17eae90945774b3753396..03f717f0737f3f28f4fff63f3680db65930f1833 100644 (file)
@@ -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) {
index c13d1dca0c49e3de7788af57898798988a1457d3..d6ceb8caf2946da82b8fed596e506f4845e88f4b 100644 (file)
@@ -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) {
index af01cf107089f2ea9d7de52cbfcc0697d56fa8d1..4e39394b1bc07c2706f6a6a5b8abe0feba39319d 100644 (file)
@@ -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,
index 82b86a2d3b08c6e03b24c7b33b0bf22c7b676b10..8fdd19e007a67380df3cf1b4e07ebc0f0720a4b8 100644 (file)
@@ -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. */
index 7ce1c7c815a5fc25888837bfa2c4d4fc3913dc95..34d706eff03aca5c1e8b38ad5e76cdf0fcbf5c24 100644 (file)
@@ -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) {
index 3bad7c92efe4f184f53cd006d707fc1f8bab154d..44017f37d291d3f2ec891534279569ba1527ebdf 100644 (file)
@@ -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