From 606805d1b78e32fe007452fd75b5d8522eb43a04 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 5 Feb 2021 22:34:03 +1100 Subject: Cleanup: use 'r_' prefix for return arguments, order last --- source/blender/blenkernel/intern/collection.c | 19 +++++---- source/blender/blenkernel/intern/mask_evaluate.c | 52 +++++++++++------------ source/blender/blenkernel/intern/mask_rasterize.c | 4 +- source/blender/blenkernel/intern/node.cc | 13 +++--- 4 files changed, 46 insertions(+), 42 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c index 601ee57fc89..dd0572f9b12 100644 --- a/source/blender/blenkernel/intern/collection.c +++ b/source/blender/blenkernel/intern/collection.c @@ -1909,7 +1909,7 @@ bool BKE_collection_move(Main *bmain, /** \name Iterators * \{ */ -/* scene collection iteractor */ +/* Scene collection iterator. */ typedef struct CollectionsIteratorData { Scene *scene; @@ -1941,10 +1941,12 @@ static void scene_collections_build_array(Collection *collection, void *data) (*array)++; } -static void scene_collections_array(Scene *scene, Collection ***collections_array, int *tot) +static void scene_collections_array(Scene *scene, + Collection ***r_collections_array, + int *r_collections_array_len) { - *collections_array = NULL; - *tot = 0; + *r_collections_array = NULL; + *r_collections_array_len = 0; if (scene == NULL) { return; @@ -1952,14 +1954,15 @@ static void scene_collections_array(Scene *scene, Collection ***collections_arra Collection *collection = scene->master_collection; BLI_assert(collection != NULL); - scene_collection_callback(collection, scene_collections_count, tot); + scene_collection_callback(collection, scene_collections_count, r_collections_array_len); - if (*tot == 0) { + if (*r_collections_array_len == 0) { return; } - Collection **array = MEM_mallocN(sizeof(Collection *) * (*tot), "CollectionArray"); - *collections_array = array; + Collection **array = MEM_mallocN(sizeof(Collection *) * (*r_collections_array_len), + "CollectionArray"); + *r_collections_array = array; scene_collection_callback(collection, scene_collections_build_array, &array); } diff --git a/source/blender/blenkernel/intern/mask_evaluate.c b/source/blender/blenkernel/intern/mask_evaluate.c index 595fd0c9550..a42836b5399 100644 --- a/source/blender/blenkernel/intern/mask_evaluate.c +++ b/source/blender/blenkernel/intern/mask_evaluate.c @@ -128,8 +128,8 @@ int BKE_mask_spline_differentiate_calc_total(const MaskSpline *spline, const uns } float (*BKE_mask_spline_differentiate_with_resolution(MaskSpline *spline, - unsigned int *tot_diff_point, - const unsigned int resol))[2] + const unsigned int resol, + unsigned int *r_tot_diff_point))[2] { MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline); @@ -140,12 +140,12 @@ float (*BKE_mask_spline_differentiate_with_resolution(MaskSpline *spline, if (spline->tot_point <= 1) { /* nothing to differentiate */ - *tot_diff_point = 0; + *r_tot_diff_point = 0; return NULL; } /* len+1 because of 'forward_diff_bezier' function */ - *tot_diff_point = tot; + *r_tot_diff_point = tot; diff_points = fp = MEM_mallocN((tot + 1) * sizeof(*diff_points), "mask spline vets"); a = spline->tot_point - 1; @@ -192,11 +192,11 @@ float (*BKE_mask_spline_differentiate_with_resolution(MaskSpline *spline, } float (*BKE_mask_spline_differentiate( - MaskSpline *spline, int width, int height, unsigned int *tot_diff_point))[2] + MaskSpline *spline, int width, int height, unsigned int *r_tot_diff_point))[2] { uint resol = BKE_mask_spline_resolution(spline, width, height); - return BKE_mask_spline_differentiate_with_resolution(spline, tot_diff_point, resol); + return BKE_mask_spline_differentiate_with_resolution(spline, resol, r_tot_diff_point); } /* ** feather points self-intersection collapse routine ** */ @@ -507,9 +507,9 @@ void BKE_mask_spline_feather_collapse_inner_loops(MaskSpline *spline, /** only called from #BKE_mask_spline_feather_differentiated_points_with_resolution() ! */ static float (*mask_spline_feather_differentiated_points_with_resolution__even( MaskSpline *spline, - unsigned int *tot_feather_point, const unsigned int resol, - const bool do_feather_isect))[2] + const bool do_feather_isect, + unsigned int *r_tot_feather_point))[2] { MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline); MaskSplinePoint *point_curr, *point_prev; @@ -569,7 +569,7 @@ static float (*mask_spline_feather_differentiated_points_with_resolution__even( point_curr++; } - *tot_feather_point = tot; + *r_tot_feather_point = tot; if ((spline->flag & MASK_SPLINE_NOINTERSECT) && do_feather_isect) { BKE_mask_spline_feather_collapse_inner_loops(spline, feather, tot); @@ -581,9 +581,9 @@ static float (*mask_spline_feather_differentiated_points_with_resolution__even( /** only called from #BKE_mask_spline_feather_differentiated_points_with_resolution() ! */ static float (*mask_spline_feather_differentiated_points_with_resolution__double( MaskSpline *spline, - unsigned int *tot_feather_point, const unsigned int resol, - const bool do_feather_isect))[2] + const bool do_feather_isect, + unsigned int *r_tot_feather_point))[2] { MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline); @@ -594,12 +594,12 @@ static float (*mask_spline_feather_differentiated_points_with_resolution__double if (spline->tot_point <= 1) { /* nothing to differentiate */ - *tot_feather_point = 0; + *r_tot_feather_point = 0; return NULL; } /* len+1 because of 'forward_diff_bezier' function */ - *tot_feather_point = tot; + *r_tot_feather_point = tot; feather = fp = MEM_mallocN((tot + 1) * sizeof(*feather), "mask spline vets"); a = spline->tot_point - 1; @@ -724,24 +724,24 @@ static float (*mask_spline_feather_differentiated_points_with_resolution__double * values align with #BKE_mask_spline_differentiate_with_resolution * when \a resol arguments match. */ -float ( - *BKE_mask_spline_feather_differentiated_points_with_resolution(MaskSpline *spline, - unsigned int *tot_feather_point, - const unsigned int resol, - const bool do_feather_isect))[2] +float (*BKE_mask_spline_feather_differentiated_points_with_resolution( + MaskSpline *spline, + const unsigned int resol, + const bool do_feather_isect, + unsigned int *r_tot_feather_point))[2] { switch (spline->offset_mode) { case MASK_SPLINE_OFFSET_EVEN: return mask_spline_feather_differentiated_points_with_resolution__even( - spline, tot_feather_point, resol, do_feather_isect); + spline, resol, do_feather_isect, r_tot_feather_point); case MASK_SPLINE_OFFSET_SMOOTH: default: return mask_spline_feather_differentiated_points_with_resolution__double( - spline, tot_feather_point, resol, do_feather_isect); + spline, resol, do_feather_isect, r_tot_feather_point); } } -float (*BKE_mask_spline_feather_points(MaskSpline *spline, int *tot_feather_point))[2] +float (*BKE_mask_spline_feather_points(MaskSpline *spline, int *r_tot_feather_point))[2] { MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline); @@ -783,7 +783,7 @@ float (*BKE_mask_spline_feather_points(MaskSpline *spline, int *tot_feather_poin } } - *tot_feather_point = tot; + *r_tot_feather_point = tot; return feather; } @@ -793,7 +793,7 @@ float *BKE_mask_point_segment_feather_diff(MaskSpline *spline, MaskSplinePoint *point, int width, int height, - unsigned int *tot_feather_point) + unsigned int *r_tot_feather_point) { float *feather, *fp; unsigned int resol = BKE_mask_spline_feather_resolution(spline, width, height); @@ -812,7 +812,7 @@ float *BKE_mask_point_segment_feather_diff(MaskSpline *spline, fp[1] = co[1] + n[1] * weight; } - *tot_feather_point = resol; + *r_tot_feather_point = resol; return feather; } @@ -821,7 +821,7 @@ float *BKE_mask_point_segment_diff(MaskSpline *spline, MaskSplinePoint *point, int width, int height, - unsigned int *tot_diff_point) + unsigned int *r_tot_diff_point) { MaskSplinePoint *points_array = BKE_mask_spline_point_array_from_point(spline, point); @@ -837,7 +837,7 @@ float *BKE_mask_point_segment_diff(MaskSpline *spline, } /* resol+1 because of 'forward_diff_bezier' function */ - *tot_diff_point = resol + 1; + *r_tot_diff_point = resol + 1; diff_points = fp = MEM_callocN(sizeof(float[2]) * (resol + 1), "mask segment vets"); for (j = 0; j < 2; j++) { diff --git a/source/blender/blenkernel/intern/mask_rasterize.c b/source/blender/blenkernel/intern/mask_rasterize.c index 583ee8f2857..d29a6e75954 100644 --- a/source/blender/blenkernel/intern/mask_rasterize.c +++ b/source/blender/blenkernel/intern/mask_rasterize.c @@ -646,11 +646,11 @@ void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle, const unsigned int resol_b = BKE_mask_spline_feather_resolution(spline, width, height) / 4; const unsigned int resol = CLAMPIS(MAX2(resol_a, resol_b), 4, 512); - diff_points = BKE_mask_spline_differentiate_with_resolution(spline, &tot_diff_point, resol); + diff_points = BKE_mask_spline_differentiate_with_resolution(spline, resol, &tot_diff_point); if (do_feather) { diff_feather_points = BKE_mask_spline_feather_differentiated_points_with_resolution( - spline, &tot_diff_feather_points, resol, false); + spline, resol, false, &tot_diff_feather_points); BLI_assert(diff_feather_points); } else { diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc index 3c9c255cacd..d78ba2a414e 100644 --- a/source/blender/blenkernel/intern/node.cc +++ b/source/blender/blenkernel/intern/node.cc @@ -3917,22 +3917,23 @@ static int node_get_deplist_recurs(bNodeTree *ntree, bNode *node, bNode ***nsort return level; } -void ntreeGetDependencyList(struct bNodeTree *ntree, struct bNode ***deplist, int *totnodes) +void ntreeGetDependencyList(struct bNodeTree *ntree, struct bNode ***r_deplist, int *r_deplist_len) { - *totnodes = 0; + *r_deplist_len = 0; /* first clear data */ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { node->done = false; - (*totnodes)++; + (*r_deplist_len)++; } - if (*totnodes == 0) { - *deplist = nullptr; + if (*r_deplist_len == 0) { + *r_deplist = nullptr; return; } bNode **nsort; - nsort = *deplist = (bNode **)MEM_callocN((*totnodes) * sizeof(bNode *), "sorted node array"); + nsort = *r_deplist = (bNode **)MEM_callocN((*r_deplist_len) * sizeof(bNode *), + "sorted node array"); /* recursive check */ LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { -- cgit v1.2.3