Cleanup: use 'r_' prefix for return arguments, order last

This commit is contained in:
Campbell Barton 2021-02-05 22:34:03 +11:00
parent f8cbd333d6
commit 606805d1b7
15 changed files with 94 additions and 86 deletions

View File

@ -269,18 +269,18 @@ int BKE_mask_spline_differentiate_calc_total(const struct MaskSpline *spline,
const unsigned int resol);
float (*BKE_mask_spline_differentiate_with_resolution(struct MaskSpline *spline,
unsigned int *tot_diff_point,
const unsigned int resol))[2];
const unsigned int resol,
unsigned int *r_tot_diff_point))[2];
void BKE_mask_spline_feather_collapse_inner_loops(struct MaskSpline *spline,
float (*feather_points)[2],
const unsigned int tot_feather_point);
float (*BKE_mask_spline_differentiate(
struct MaskSpline *spline, int width, int height, unsigned int *tot_diff_point))[2];
struct MaskSpline *spline, int width, int height, unsigned int *r_tot_diff_point))[2];
float (*BKE_mask_spline_feather_differentiated_points_with_resolution(
struct 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];
/* *** mask point functions which involve evaluation *** */
float (*BKE_mask_spline_feather_points(struct MaskSpline *spline, int *tot_feather_point))[2];
@ -289,7 +289,7 @@ float *BKE_mask_point_segment_diff(struct MaskSpline *spline,
struct MaskSplinePoint *point,
int width,
int height,
unsigned int *tot_diff_point);
unsigned int *r_tot_diff_point);
float *BKE_mask_point_segment_feather_diff(struct MaskSpline *spline,
struct MaskSplinePoint *point,

View File

@ -453,7 +453,9 @@ void ntreeUpdateTree(struct Main *main, struct bNodeTree *ntree);
void ntreeUpdateAllNew(struct Main *main);
void ntreeUpdateAllUsers(struct Main *main, struct ID *id);
void ntreeGetDependencyList(struct bNodeTree *ntree, struct bNode ***deplist, int *totnodes);
void ntreeGetDependencyList(struct bNodeTree *ntree,
struct bNode ***r_deplist,
int *r_deplist_len);
/* XXX old trees handle output flags automatically based on special output
* node types and last active selection.

View File

@ -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);
}

View File

@ -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++) {

View File

@ -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 {

View File

@ -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) {

View File

@ -134,8 +134,8 @@ struct LinkNode *BLO_blendhandle_get_datablock_names(BlendHandle *bh,
int *r_tot_names);
struct LinkNode *BLO_blendhandle_get_datablock_info(BlendHandle *bh,
int ofblocktype,
int *tot_info_items);
struct LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype, int *tot_prev);
int *r_tot_info_items);
struct LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype, int *r_tot_prev);
struct LinkNode *BLO_blendhandle_get_linkable_groups(BlendHandle *bh);
void BLO_blendhandle_close(BlendHandle *bh);

View File

@ -177,7 +177,9 @@ LinkNode *BLO_blendhandle_get_datablock_names(BlendHandle *bh,
* \return A BLI_linklist of BLODataBlockInfo *. The links and #BLODataBlockInfo.asset_data should
* be freed with MEM_freeN.
*/
LinkNode *BLO_blendhandle_get_datablock_info(BlendHandle *bh, int ofblocktype, int *tot_info_items)
LinkNode *BLO_blendhandle_get_datablock_info(BlendHandle *bh,
int ofblocktype,
int *r_tot_info_items)
{
FileData *fd = (FileData *)bh;
LinkNode *infos = NULL;
@ -208,7 +210,7 @@ LinkNode *BLO_blendhandle_get_datablock_info(BlendHandle *bh, int ofblocktype, i
}
}
*tot_info_items = tot;
*r_tot_info_items = tot;
return infos;
}
@ -218,10 +220,10 @@ LinkNode *BLO_blendhandle_get_datablock_info(BlendHandle *bh, int ofblocktype, i
*
* \param bh: The blendhandle to access.
* \param ofblocktype: The type of names to get.
* \param tot_prev: The length of the returned list.
* \param r_tot_prev: The length of the returned list.
* \return A BLI_linklist of PreviewImage. The PreviewImage links should be freed with malloc.
*/
LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype, int *tot_prev)
LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype, int *r_tot_prev)
{
FileData *fd = (FileData *)bh;
LinkNode *previews = NULL;
@ -302,7 +304,7 @@ LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype, int *to
}
}
*tot_prev = tot;
*r_tot_prev = tot;
return previews;
}

View File

@ -370,7 +370,7 @@ static int gpencil_find_end_of_stroke_idx(tGpTimingData *gtd,
static void gpencil_stroke_path_animation_preprocess_gaps(tGpTimingData *gtd,
RNG *rng,
int *nbr_gaps,
float *tot_gaps_time)
float *r_tot_gaps_time)
{
float delta_time = 0.0f;
@ -387,10 +387,10 @@ static void gpencil_stroke_path_animation_preprocess_gaps(tGpTimingData *gtd,
}
gtd->tot_time -= delta_time;
*tot_gaps_time = (float)(*nbr_gaps) * gtd->gap_duration;
gtd->tot_time += *tot_gaps_time;
*r_tot_gaps_time = (float)(*nbr_gaps) * gtd->gap_duration;
gtd->tot_time += *r_tot_gaps_time;
if (G.debug & G_DEBUG) {
printf("%f, %f, %f, %d\n", gtd->tot_time, delta_time, *tot_gaps_time, *nbr_gaps);
printf("%f, %f, %f, %d\n", gtd->tot_time, delta_time, *r_tot_gaps_time, *nbr_gaps);
}
if (gtd->gap_randomness > 0.0f) {
BLI_rng_srandom(rng, gtd->seed);

View File

@ -539,7 +539,7 @@ static void draw_spline_curve(const bContext *C,
uint tot_feather_point;
float(*feather_points)[2];
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 (!diff_points) {
return;
@ -550,7 +550,7 @@ static void draw_spline_curve(const bContext *C,
}
feather_points = BKE_mask_spline_feather_differentiated_points_with_resolution(
spline, &tot_feather_point, resol, (is_fill != false));
spline, resol, (is_fill != false), &tot_feather_point);
/* draw feather */
mask_spline_feather_color_get(mask_layer, spline, is_spline_sel, rgb_tmp);

View File

@ -865,11 +865,11 @@ bool PyC_NameSpace_ImportArray(PyObject *py_dict, const char *imports[])
}
/* restore MUST be called after this */
void PyC_MainModule_Backup(PyObject **main_mod)
void PyC_MainModule_Backup(PyObject **r_main_mod)
{
PyObject *modules = PyImport_GetModuleDict();
*main_mod = PyDict_GetItemString(modules, "__main__");
Py_XINCREF(*main_mod); /* don't free */
*r_main_mod = PyDict_GetItemString(modules, "__main__");
Py_XINCREF(*r_main_mod); /* don't free */
}
void PyC_MainModule_Restore(PyObject *main_mod)

View File

@ -85,7 +85,7 @@ PyObject *PyC_DefaultNameSpace(const char *filename);
void PyC_RunQuicky(const char *filepath, int n, ...);
bool PyC_NameSpace_ImportArray(PyObject *py_dict, const char *imports[]);
void PyC_MainModule_Backup(PyObject **main_mod);
void PyC_MainModule_Backup(PyObject **r_main_mod);
void PyC_MainModule_Restore(PyObject *main_mod);
void PyC_SetHomePath(const char *py_path_bundle);

View File

@ -32,8 +32,8 @@ struct Sequence;
struct Sequence *SEQ_select_active_get(struct Scene *scene);
int SEQ_select_active_get_pair(struct Scene *scene,
struct Sequence **seq_act,
struct Sequence **seq_other);
struct Sequence **r_seq_act,
struct Sequence **r_seq_other);
void SEQ_select_active_set(struct Scene *scene, struct Sequence *seq);
#ifdef __cplusplus

View File

@ -75,31 +75,31 @@ static void seq_build_array(ListBase *seqbase, Sequence ***array, int depth)
}
static void seq_array(Editing *ed,
Sequence ***seqarray,
int *tot,
const bool use_current_sequences)
const bool use_current_sequences,
Sequence ***r_seqarray,
int *r_seqarray_len)
{
Sequence **array;
*seqarray = NULL;
*tot = 0;
*r_seqarray = NULL;
*r_seqarray_len = 0;
if (ed == NULL) {
return;
}
if (use_current_sequences) {
seq_count(ed->seqbasep, tot);
seq_count(ed->seqbasep, r_seqarray_len);
}
else {
seq_count(&ed->seqbase, tot);
seq_count(&ed->seqbase, r_seqarray_len);
}
if (*tot == 0) {
if (*r_seqarray_len == 0) {
return;
}
*seqarray = array = MEM_mallocN(sizeof(Sequence *) * (*tot), "SeqArray");
*r_seqarray = array = MEM_mallocN(sizeof(Sequence *) * (*r_seqarray_len), "SeqArray");
if (use_current_sequences) {
seq_build_array(ed->seqbasep, &array, 0);
}
@ -111,7 +111,7 @@ static void seq_array(Editing *ed,
void SEQ_iterator_begin(Editing *ed, SeqIterator *iter, const bool use_current_sequences)
{
memset(iter, 0, sizeof(*iter));
seq_array(ed, &iter->array, &iter->tot, use_current_sequences);
seq_array(ed, use_current_sequences, &iter->array, &iter->tot);
if (iter->tot) {
iter->cur = 0;

View File

@ -54,29 +54,29 @@ void SEQ_select_active_set(Scene *scene, Sequence *seq)
ed->act_seq = seq;
}
int SEQ_select_active_get_pair(Scene *scene, Sequence **seq_act, Sequence **seq_other)
int SEQ_select_active_get_pair(Scene *scene, Sequence **r_seq_act, Sequence **r_seq_other)
{
Editing *ed = SEQ_editing_get(scene, false);
*seq_act = SEQ_select_active_get(scene);
*r_seq_act = SEQ_select_active_get(scene);
if (*seq_act == NULL) {
if (*r_seq_act == NULL) {
return 0;
}
Sequence *seq;
*seq_other = NULL;
*r_seq_other = NULL;
for (seq = ed->seqbasep->first; seq; seq = seq->next) {
if (seq->flag & SELECT && (seq != (*seq_act))) {
if (*seq_other) {
if (seq->flag & SELECT && (seq != (*r_seq_act))) {
if (*r_seq_other) {
return 0;
}
*seq_other = seq;
*r_seq_other = seq;
}
}
return (*seq_other != NULL);
return (*r_seq_other != NULL);
}