diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-09-22 19:28:46 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-09-24 08:55:02 +0400 |
commit | 059e0dafb41010b440f31323acbb93e61e72efdd (patch) | |
tree | e9e14150dca9d5d1b288645abfd1955bf37707d8 /source | |
parent | 31833d2dc84a273e98716a4c13c79292cdecf48b (diff) |
Cleanup: const correctness for BLI_sortlist
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/mask.c | 6 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/tracking.c | 36 | ||||
-rw-r--r-- | source/blender/blenlib/BLI_listbase.h | 4 | ||||
-rw-r--r-- | source/blender/blenlib/intern/listbase.c | 4 | ||||
-rw-r--r-- | source/blender/blenlib/intern/scanfill_utils.c | 6 | ||||
-rw-r--r-- | source/blender/editors/armature/editarmature_sketch.c | 4 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_layout.c | 2 | ||||
-rw-r--r-- | source/blender/editors/object/object_vgroup.c | 6 | ||||
-rw-r--r-- | source/blender/editors/space_image/image_ops.c | 6 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_relationships.c | 10 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_conversions.c | 12 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_snap.c | 6 |
13 files changed, 53 insertions, 53 deletions
diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c index 1c40446c217..83ad2f1b2d2 100644 --- a/source/blender/blenkernel/intern/mask.c +++ b/source/blender/blenkernel/intern/mask.c @@ -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; diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index b09016506e3..e9468b2df24 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -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; diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index b77cd744a18..5458d889800 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -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; diff --git a/source/blender/blenlib/BLI_listbase.h b/source/blender/blenlib/BLI_listbase.h index 697ba863603..fb388977ddf 100644 --- a/source/blender/blenlib/BLI_listbase.h +++ b/source/blender/blenlib/BLI_listbase.h @@ -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); diff --git a/source/blender/blenlib/intern/listbase.c b/source/blender/blenlib/intern/listbase.c index abf15d57cf7..d9cf8971246 100644 --- a/source/blender/blenlib/intern/listbase.c +++ b/source/blender/blenlib/intern/listbase.c @@ -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; diff --git a/source/blender/blenlib/intern/scanfill_utils.c b/source/blender/blenlib/intern/scanfill_utils.c index 828cb3a580b..9fc1db1f1e4 100644 --- a/source/blender/blenlib/intern/scanfill_utils.c +++ b/source/blender/blenlib/intern/scanfill_utils.c @@ -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); diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c index ba105325b97..d75a23a6322 100644 --- a/source/blender/editors/armature/editarmature_sketch.c +++ b/source/blender/editors/armature/editarmature_sketch.c @@ -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) { diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 27af550b173..c2bd6d307d1 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -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; diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index 6897861c81c..777bbabb6e8 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -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); } diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index c87e547b6ea..cd95e67f070 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -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; diff --git a/source/blender/editors/space_node/node_relationships.c b/source/blender/editors/space_node/node_relationships.c index 97a2383c03f..973ce56857c 100644 --- a/source/blender/editors/space_node/node_relationships.c +++ b/source/blender/editors/space_node/node_relationships.c @@ -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; diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index aa215613841..b7098085ac2 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -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; diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index fcdebad02d1..af563f71376 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -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) { |