[Bf-blender-cvs] [059e0da] master: Cleanup: const correctness for BLI_sortlist

Campbell Barton noreply at git.blender.org
Wed Sep 24 10:52:23 CEST 2014


Commit: 059e0dafb41010b440f31323acbb93e61e72efdd
Author: Campbell Barton
Date:   Tue Sep 23 01:28:46 2014 +1000
Branches: master
https://developer.blender.org/rB059e0dafb41010b440f31323acbb93e61e72efdd

Cleanup: const correctness for BLI_sortlist

===================================================================

M	source/blender/blenkernel/intern/mask.c
M	source/blender/blenkernel/intern/object.c
M	source/blender/blenkernel/intern/tracking.c
M	source/blender/blenlib/BLI_listbase.h
M	source/blender/blenlib/intern/listbase.c
M	source/blender/blenlib/intern/scanfill_utils.c
M	source/blender/editors/armature/editarmature_sketch.c
M	source/blender/editors/interface/interface_layout.c
M	source/blender/editors/object/object_vgroup.c
M	source/blender/editors/space_image/image_ops.c
M	source/blender/editors/space_node/node_relationships.c
M	source/blender/editors/transform/transform_conversions.c
M	source/blender/editors/transform/transform_snap.c

===================================================================

diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c
index 1c40446..83ad2f1 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 b090165..e9468b2 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 b77cd74..5458d88 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 697ba86..fb38897 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 abf15d5..d9cf897 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 828cb3a..9fc1db1 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 ba10532..d75a23a 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 27af550..c2bd6d3 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 6897861..777bbab 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

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list