Cleanup: use listbase macros

This commit is contained in:
Campbell Barton
2023-08-07 22:02:17 +10:00
parent ae4286d12b
commit b086bd411e
8 changed files with 17 additions and 26 deletions

View File

@@ -217,7 +217,7 @@ static bool testbuffer_item_validate(TestBuffer *tb)
static bool testbuffer_list_validate(const ListBase *lb)
{
for (TestBuffer *tb = (TestBuffer *)lb->first; tb; tb = tb->next) {
LISTBASE_FOREACH (TestBuffer *, tb, lb) {
if (!testbuffer_item_validate(tb)) {
return false;
}
@@ -228,7 +228,7 @@ static bool testbuffer_list_validate(const ListBase *lb)
static void testbuffer_list_data_randomize(ListBase *lb, uint random_seed)
{
for (TestBuffer *tb = (TestBuffer *)lb->first; tb; tb = tb->next) {
LISTBASE_FOREACH (TestBuffer *, tb, lb) {
BLI_array_randomize((void *)tb->data, 1, tb->data_len, random_seed++);
}
}
@@ -244,7 +244,7 @@ static void testbuffer_list_store_populate(BArrayStore *bs, ListBase *lb)
static void testbuffer_list_store_clear(BArrayStore *bs, ListBase *lb)
{
for (TestBuffer *tb = (TestBuffer *)lb->first; tb; tb = tb->next) {
LISTBASE_FOREACH (TestBuffer *, tb, lb) {
BLI_array_store_state_remove(bs, tb->state);
tb->state = nullptr;
}

View File

@@ -221,7 +221,7 @@ TEST(task, MempoolIterTLS)
/* Check that all elements are added into the list once. */
int number_accum = 0;
for (LinkData *link = (LinkData *)tls_data.accumulate_items->first; link; link = link->next) {
LISTBASE_FOREACH (LinkData *, link, tls_data.accumulate_items) {
int *data = (int *)link->data;
number_accum += *data;
}

View File

@@ -541,8 +541,6 @@ BMLog *BM_log_from_existing_entries_create(BMesh *bm, BMLogEntry *entry)
void BM_log_free(BMLog *log)
{
BMLogEntry *entry;
if (log->unused_ids) {
range_tree_uint_free(log->unused_ids);
}
@@ -557,7 +555,7 @@ void BM_log_free(BMLog *log)
/* Clear the BMLog references within each entry, but do not free
* the entries themselves */
for (entry = static_cast<BMLogEntry *>(log->entries.first); entry; entry = entry->next) {
LISTBASE_FOREACH (BMLogEntry *, entry, &log->entries) {
entry->log = nullptr;
}

View File

@@ -2033,7 +2033,6 @@ static void bm_loop_normal_mark_indiv_do_loop(BMLoop *l,
/* Mark the individual clnors to be edited, if multiple selection methods are used. */
static int bm_loop_normal_mark_indiv(BMesh *bm, BLI_bitmap *loops, const bool do_all_loops_of_vert)
{
BMEditSelection *ese, *ese_prev;
int totloopsel = 0;
const bool sel_verts = (bm->selectmode & SCE_SELECT_VERTEX) != 0;
@@ -2052,11 +2051,11 @@ static int bm_loop_normal_mark_indiv(BMesh *bm, BLI_bitmap *loops, const bool do
* but it is not designed to be used with huge selection sets,
* rather with only a few items selected at most. */
/* Goes from last selected to the first selected element. */
for (ese = static_cast<BMEditSelection *>(bm->selected.last); ese; ese = ese->prev) {
LISTBASE_FOREACH_BACKWARD (BMEditSelection *, ese, &bm->selected) {
if (ese->htype == BM_FACE) {
/* If current face is selected,
* then any verts to be edited must have been selected before it. */
for (ese_prev = ese->prev; ese_prev; ese_prev = ese_prev->prev) {
for (BMEditSelection *ese_prev = ese->prev; ese_prev; ese_prev = ese_prev->prev) {
if (ese_prev->htype == BM_VERT) {
bm_loop_normal_mark_indiv_do_loop(
BM_face_vert_share_loop((BMFace *)ese->ele, (BMVert *)ese_prev->ele),

View File

@@ -2843,7 +2843,6 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd)
KnifeEdge *kfe;
KnifeVert *v;
ListBase *list;
Ref *ref;
KnifeLineHit *linehits = nullptr;
BLI_array_declare(linehits);
SmallHashIter hiter;
@@ -2956,7 +2955,7 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd)
BLI_smallhash_insert(&fobs, uintptr_t(f), (void *)uintptr_t(ob_index));
list = knife_get_face_kedges(kcd, ob, ob_index, f);
for (ref = static_cast<Ref *>(list->first); ref; ref = ref->next) {
LISTBASE_FOREACH (Ref *, ref, list) {
kfe = static_cast<KnifeEdge *>(ref->ref);
if (kfe->is_invalid) {
continue;

View File

@@ -1505,7 +1505,6 @@ static int bake(const BakeAPIRender *bkr,
}
if (bkr->is_selected_to_active) {
CollectionPointerLink *link;
int i = 0;
/* prepare cage mesh */
@@ -1561,8 +1560,7 @@ static int bake(const BakeAPIRender *bkr,
MEM_callocN(sizeof(BakeHighPolyData) * tot_highpoly, "bake high poly objects"));
/* populate highpoly array */
for (link = static_cast<CollectionPointerLink *>(selected_objects->first); link;
link = link->next) {
LISTBASE_FOREACH (CollectionPointerLink *, link, selected_objects) {
Object *ob_iter = static_cast<Object *>(link->ptr.data);
if (ob_iter == ob_low) {

View File

@@ -188,12 +188,10 @@ static void topbar_header_region_message_subscribe(const wmRegionMessageSubscrib
static void recent_files_menu_draw(const bContext * /*C*/, Menu *menu)
{
RecentFile *recent;
uiLayout *layout = menu->layout;
uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_DEFAULT);
if (!BLI_listbase_is_empty(&G.recent_files)) {
for (recent = static_cast<RecentFile *>(G.recent_files.first); (recent); recent = recent->next)
{
LISTBASE_FOREACH (RecentFile *, recent, &G.recent_files) {
const char *file = BLI_path_basename(recent->filepath);
const int icon = BKE_blendfile_extension_check(file) ? ICON_FILE_BLEND : ICON_FILE_BACKUP;
PointerRNA ptr;

View File

@@ -532,7 +532,6 @@ static int gizmo_3d_foreach_selected(const bContext *C,
Depsgraph *depsgraph = CTX_data_expect_evaluated_depsgraph(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
View3D *v3d = static_cast<View3D *>(area->spacedata.first);
Base *base;
bGPdata *gpd = CTX_data_gpencil_data(C);
const bool is_gp_edit = GPENCIL_ANY_MODE(gpd);
const bool is_curve_edit = GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd);
@@ -878,15 +877,15 @@ static int gizmo_3d_foreach_selected(const bContext *C,
/* we need the one selected object, if its not active */
BKE_view_layer_synced_ensure(scene, view_layer);
base = BKE_view_layer_active_base_get(view_layer);
ob = base ? base->object : nullptr;
if (base && ((base->flag & BASE_SELECTED) == 0)) {
ob = nullptr;
{
Base *base = BKE_view_layer_active_base_get(view_layer);
ob = base ? base->object : nullptr;
if (base && ((base->flag & BASE_SELECTED) == 0)) {
ob = nullptr;
}
}
for (base = static_cast<Base *>(BKE_view_layer_object_bases_get(view_layer)->first); base;
base = base->next)
{
LISTBASE_FOREACH (Base *, base, BKE_view_layer_object_bases_get(view_layer)) {
if (!BASE_SELECTED_EDITABLE(v3d, base)) {
continue;
}