Cleanup: const correctness for BLI_sortlist

This commit is contained in:
2014-09-23 01:28:46 +10:00
parent 31833d2dc8
commit 059e0dafb4
13 changed files with 53 additions and 53 deletions

View File

@@ -1821,10 +1821,10 @@ void BKE_mask_layer_shape_unlink(MaskLayer *masklay, MaskLayerShape *masklay_sha
BKE_mask_layer_shape_free(masklay_shape);
}
static int mask_layer_shape_sort_cb(void *masklay_shape_a_ptr, void *masklay_shape_b_ptr)
static int mask_layer_shape_sort_cb(const void *masklay_shape_a_ptr, const void *masklay_shape_b_ptr)
{
MaskLayerShape *masklay_shape_a = (MaskLayerShape *)masklay_shape_a_ptr;
MaskLayerShape *masklay_shape_b = (MaskLayerShape *)masklay_shape_b_ptr;
const MaskLayerShape *masklay_shape_a = masklay_shape_a_ptr;
const MaskLayerShape *masklay_shape_b = masklay_shape_b_ptr;
if (masklay_shape_a->frame < masklay_shape_b->frame) return -1;
else if (masklay_shape_a->frame > masklay_shape_b->frame) return 1;

View File

@@ -3242,9 +3242,9 @@ bool BKE_boundbox_ray_hit_check(
return result;
}
static int pc_cmp(void *a, void *b)
static int pc_cmp(const void *a, const void *b)
{
LinkData *ad = a, *bd = b;
const LinkData *ad = a, *bd = b;
if (GET_INT_FROM_POINTER(ad->data) > GET_INT_FROM_POINTER(bd->data))
return 1;
else return 0;

View File

@@ -2185,10 +2185,10 @@ void BKE_tracking_disable_channels(ImBuf *ibuf, bool disable_red, bool disable_g
/* ** Channels sort comparators ** */
static int channels_alpha_sort(void *a, void *b)
static int channels_alpha_sort(const void *a, const void *b)
{
MovieTrackingDopesheetChannel *channel_a = a;
MovieTrackingDopesheetChannel *channel_b = b;
const MovieTrackingDopesheetChannel *channel_a = a;
const MovieTrackingDopesheetChannel *channel_b = b;
if (BLI_strcasecmp(channel_a->track->name, channel_b->track->name) > 0)
return 1;
@@ -2196,10 +2196,10 @@ static int channels_alpha_sort(void *a, void *b)
return 0;
}
static int channels_total_track_sort(void *a, void *b)
static int channels_total_track_sort(const void *a, const void *b)
{
MovieTrackingDopesheetChannel *channel_a = a;
MovieTrackingDopesheetChannel *channel_b = b;
const MovieTrackingDopesheetChannel *channel_a = a;
const MovieTrackingDopesheetChannel *channel_b = b;
if (channel_a->total_frames > channel_b->total_frames)
return 1;
@@ -2207,10 +2207,10 @@ static int channels_total_track_sort(void *a, void *b)
return 0;
}
static int channels_longest_segment_sort(void *a, void *b)
static int channels_longest_segment_sort(const void *a, const void *b)
{
MovieTrackingDopesheetChannel *channel_a = a;
MovieTrackingDopesheetChannel *channel_b = b;
const MovieTrackingDopesheetChannel *channel_a = a;
const MovieTrackingDopesheetChannel *channel_b = b;
if (channel_a->max_segment > channel_b->max_segment)
return 1;
@@ -2218,10 +2218,10 @@ static int channels_longest_segment_sort(void *a, void *b)
return 0;
}
static int channels_average_error_sort(void *a, void *b)
static int channels_average_error_sort(const void *a, const void *b)
{
MovieTrackingDopesheetChannel *channel_a = a;
MovieTrackingDopesheetChannel *channel_b = b;
const MovieTrackingDopesheetChannel *channel_a = a;
const MovieTrackingDopesheetChannel *channel_b = b;
if (channel_a->track->error > channel_b->track->error)
return 1;
@@ -2229,7 +2229,7 @@ static int channels_average_error_sort(void *a, void *b)
return 0;
}
static int channels_alpha_inverse_sort(void *a, void *b)
static int channels_alpha_inverse_sort(const void *a, const void *b)
{
if (channels_alpha_sort(a, b))
return 0;
@@ -2237,7 +2237,7 @@ static int channels_alpha_inverse_sort(void *a, void *b)
return 1;
}
static int channels_total_track_inverse_sort(void *a, void *b)
static int channels_total_track_inverse_sort(const void *a, const void *b)
{
if (channels_total_track_sort(a, b))
return 0;
@@ -2245,7 +2245,7 @@ static int channels_total_track_inverse_sort(void *a, void *b)
return 1;
}
static int channels_longest_segment_inverse_sort(void *a, void *b)
static int channels_longest_segment_inverse_sort(const void *a, const void *b)
{
if (channels_longest_segment_sort(a, b))
return 0;
@@ -2253,10 +2253,10 @@ static int channels_longest_segment_inverse_sort(void *a, void *b)
return 1;
}
static int channels_average_error_inverse_sort(void *a, void *b)
static int channels_average_error_inverse_sort(const void *a, const void *b)
{
MovieTrackingDopesheetChannel *channel_a = a;
MovieTrackingDopesheetChannel *channel_b = b;
const MovieTrackingDopesheetChannel *channel_a = a;
const MovieTrackingDopesheetChannel *channel_b = b;
if (channel_a->track->error < channel_b->track->error)
return 1;

View File

@@ -67,8 +67,8 @@ void *BLI_poptail(ListBase *listbase) ATTR_NONNULL(1);
void BLI_addhead(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1);
void BLI_insertlinkbefore(struct ListBase *listbase, void *vnextlink, void *vnewlink) ATTR_NONNULL(1);
void BLI_insertlinkafter(struct ListBase *listbase, void *vprevlink, void *vnewlink) ATTR_NONNULL(1);
void BLI_sortlist(struct ListBase *listbase, int (*cmp)(void *, void *)) ATTR_NONNULL(1, 2);
void BLI_sortlist_r(ListBase *listbase, void *thunk, int (*cmp)(void *, void *, void *)) ATTR_NONNULL(1, 3);
void BLI_sortlist(struct ListBase *listbase, int (*cmp)(const void *, const void *)) ATTR_NONNULL(1, 2);
void BLI_sortlist_r(ListBase *listbase, void *thunk, int (*cmp)(void *, const void *, const void *)) ATTR_NONNULL(1, 3);
void BLI_freelist(struct ListBase *listbase) ATTR_NONNULL(1);
int BLI_countlist(const struct ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1);
void BLI_freelinkN(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1);

View File

@@ -173,7 +173,7 @@ void BLI_freelinkN(ListBase *listbase, void *vlink)
* (which should return 1 iff its first arg should come after its second arg).
* This uses insertion sort, so NOT ok for large list.
*/
void BLI_sortlist(ListBase *listbase, int (*cmp)(void *, void *))
void BLI_sortlist(ListBase *listbase, int (*cmp)(const void *, const void *))
{
Link *current = NULL;
Link *previous = NULL;
@@ -195,7 +195,7 @@ void BLI_sortlist(ListBase *listbase, int (*cmp)(void *, void *))
}
}
void BLI_sortlist_r(ListBase *listbase, void *thunk, int (*cmp)(void *, void *, void *))
void BLI_sortlist_r(ListBase *listbase, void *thunk, int (*cmp)(void *, const void *, const void *))
{
Link *current = NULL;
Link *previous = NULL;

View File

@@ -132,12 +132,12 @@ static ListBase *edge_isect_ls_add(GHash *isect_hash, ScanFillEdge *eed, ScanFil
return e_ls;
}
static int edge_isect_ls_sort_cb(void *thunk, void *def_a_ptr, void *def_b_ptr)
static int edge_isect_ls_sort_cb(void *thunk, const void *def_a_ptr, const void *def_b_ptr)
{
const float *co = thunk;
ScanFillIsect *i_a = (ScanFillIsect *)(((LinkData *)def_a_ptr)->data);
ScanFillIsect *i_b = (ScanFillIsect *)(((LinkData *)def_b_ptr)->data);
const ScanFillIsect *i_a = ((LinkData *)def_a_ptr)->data;
const ScanFillIsect *i_b = ((LinkData *)def_b_ptr)->data;
const float a = len_squared_v2v2(co, i_a->co);
const float b = len_squared_v2v2(co, i_b->co);

View File

@@ -1492,9 +1492,9 @@ static int sk_getSelfIntersections(bContext *C, ListBase *list, SK_Stroke *gestu
return added;
}
static int cmpIntersections(void *i1, void *i2)
static int cmpIntersections(const void *i1, const void *i2)
{
SK_Intersection *isect1 = i1, *isect2 = i2;
const SK_Intersection *isect1 = i1, *isect2 = i2;
if (isect1->stroke == isect2->stroke) {
if (isect1->before < isect2->before) {

View File

@@ -1442,7 +1442,7 @@ typedef struct CollItemSearch {
int iconid;
} CollItemSearch;
static int sort_search_items_list(void *a, void *b)
static int sort_search_items_list(const void *a, const void *b)
{
CollItemSearch *cis1 = (CollItemSearch *)a;
CollItemSearch *cis2 = (CollItemSearch *)b;

View File

@@ -4324,10 +4324,10 @@ static int vgroup_do_remap(Object *ob, const char *name_array, wmOperator *op)
return OPERATOR_FINISHED;
}
static int vgroup_sort_name(void *def_a_ptr, void *def_b_ptr)
static int vgroup_sort_name(const void *def_a_ptr, const void *def_b_ptr)
{
bDeformGroup *def_a = (bDeformGroup *)def_a_ptr;
bDeformGroup *def_b = (bDeformGroup *)def_b_ptr;
const bDeformGroup *def_a = def_a_ptr;
const bDeformGroup *def_b = def_b_ptr;
return BLI_natstrcmp(def_a->name, def_b->name);
}

View File

@@ -1001,10 +1001,10 @@ static void image_sequence_get_frames(PointerRNA *ptr, ListBase *frames, char *p
RNA_END
}
static int image_cmp_frame(void *a, void *b)
static int image_cmp_frame(const void *a, const void *b)
{
ImageFrame *frame_a = (ImageFrame *)a;
ImageFrame *frame_b = (ImageFrame *)b;
const ImageFrame *frame_a = a;
const ImageFrame *frame_b = b;
if (frame_a->framenr < frame_b->framenr) return -1;
if (frame_a->framenr > frame_b->framenr) return 1;

View File

@@ -67,12 +67,12 @@ typedef struct bNodeListItem {
struct bNode *node;
} bNodeListItem;
static int sort_nodes_locx(void *a, void *b)
static int sort_nodes_locx(const void *a, const void *b)
{
bNodeListItem *nli1 = (bNodeListItem *)a;
bNodeListItem *nli2 = (bNodeListItem *)b;
bNode *node1 = nli1->node;
bNode *node2 = nli2->node;
const bNodeListItem *nli1 = a;
const bNodeListItem *nli2 = b;
const bNode *node1 = nli1->node;
const bNode *node2 = nli2->node;
if (node1->locx > node2->locx)
return 1;

View File

@@ -3068,10 +3068,10 @@ static void createTransNlaData(bContext *C, TransInfo *t)
/* ********************* ACTION EDITOR ****************** */
static int gpf_cmp_frame(void *thunk, void *a, void *b)
static int gpf_cmp_frame(void *thunk, const void *a, const void *b)
{
bGPDframe *frame_a = a;
bGPDframe *frame_b = b;
const bGPDframe *frame_a = a;
const bGPDframe *frame_b = b;
if (frame_a->framenum < frame_b->framenum) return -1;
if (frame_a->framenum > frame_b->framenum) return 1;
@@ -3085,10 +3085,10 @@ static int gpf_cmp_frame(void *thunk, void *a, void *b)
return 0;
}
static int masklay_shape_cmp_frame(void *thunk, void *a, void *b)
static int masklay_shape_cmp_frame(void *thunk, const void *a, const void *b)
{
MaskLayerShape *frame_a = a;
MaskLayerShape *frame_b = b;
const MaskLayerShape *frame_a = a;
const MaskLayerShape *frame_b = b;
if (frame_a->frame < frame_b->frame) return -1;
if (frame_a->frame > frame_b->frame) return 1;

View File

@@ -2036,10 +2036,10 @@ bool snapObjectsRayEx(Scene *scene, Base *base_act, View3D *v3d, ARegion *ar, Ob
/******************** PEELING *********************************/
static int cmpPeel(void *arg1, void *arg2)
static int cmpPeel(const void *arg1, const void *arg2)
{
DepthPeel *p1 = arg1;
DepthPeel *p2 = arg2;
const DepthPeel *p1 = arg1;
const DepthPeel *p2 = arg2;
int val = 0;
if (p1->depth < p2->depth) {