[Bf-blender-cvs] [483d8da] master: Code cleanup: use 'const' for arrays (blenlib)

Campbell Barton noreply at git.blender.org
Sat Apr 26 16:29:38 CEST 2014


Commit: 483d8da9bcfa1eeef950ba45633c5fb49fb7f93b
Author: Campbell Barton
Date:   Sun Apr 27 00:20:55 2014 +1000
https://developer.blender.org/rB483d8da9bcfa1eeef950ba45633c5fb49fb7f93b

Code cleanup: use 'const' for arrays (blenlib)

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

M	source/blender/blenlib/intern/math_geom.c
M	source/blender/blenlib/intern/path_util.c
M	source/blender/blenlib/intern/scanfill.c
M	source/blender/blenlib/intern/string.c
M	source/blender/blenlib/intern/string_utf8.c

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

diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index 85a2974..5638d8e 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -95,8 +95,8 @@ float normal_quad_v3(float n[3], const float v1[3], const float v2[3], const flo
  */
 float normal_poly_v3(float n[3], const float verts[][3], unsigned int nr)
 {
-	float const *v_prev = verts[nr - 1];
-	float const *v_curr = verts[0];
+	const float const *v_prev = verts[nr - 1];
+	const float const *v_curr = verts[0];
 	unsigned int i;
 
 	zero_v3(n);
@@ -2554,7 +2554,7 @@ void interp_weights_poly_v3(float *w, float v[][3], const int n, const float co[
 {
 	const float eps = 0.00001f;  /* take care, low values cause [#36105] */
 	const float eps_sq = eps * eps;
-	float *v_curr, *v_next;
+	const float *v_curr, *v_next;
 	float ht_prev, ht;  /* half tangents */
 	float totweight = 0.0f;
 	int i = 0;
@@ -2623,7 +2623,7 @@ void interp_weights_poly_v2(float *w, float v[][2], const int n, const float co[
 {
 	const float eps = 0.00001f;  /* take care, low values cause [#36105] */
 	const float eps_sq = eps * eps;
-	float *v_curr, *v_next;
+	const float *v_curr, *v_next;
 	float ht_prev, ht;  /* half tangents */
 	float totweight = 0.0f;
 	int i = 0;
diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c
index 118cd50..0be2e84 100644
--- a/source/blender/blenlib/intern/path_util.c
+++ b/source/blender/blenlib/intern/path_util.c
@@ -646,8 +646,8 @@ void BLI_path_rel(char *file, const char *relfile)
 	if (lslash) {
 		/* find the prefix of the filename that is equal for both filenames.
 		 * This is replaced by the two slashes at the beginning */
-		char *p = temp;
-		char *q = file;
+		const char *p = temp;
+		const char *q = file;
 		char *r = res;
 
 #ifdef WIN32
@@ -1723,7 +1723,7 @@ bool BLI_testextensie_glob(const char *str, const char *ext_fnmatch)
 	char pattern[16];
 
 	while (ext_step[0]) {
-		char *ext_next;
+		const char *ext_next;
 		int len_ext;
 
 		if ((ext_next = strchr(ext_step, ';'))) {
@@ -2057,8 +2057,8 @@ int BLI_rebase_path(char *abs, size_t abs_len,
  */
 const char *BLI_first_slash(const char *string)
 {
-	char * const ffslash = strchr(string, '/');
-	char * const fbslash = strchr(string, '\\');
+	const char * const ffslash = strchr(string, '/');
+	const char * const fbslash = strchr(string, '\\');
 	
 	if (!ffslash) return fbslash;
 	else if (!fbslash) return ffslash;
diff --git a/source/blender/blenlib/intern/scanfill.c b/source/blender/blenlib/intern/scanfill.c
index 69049b5..05e4984 100644
--- a/source/blender/blenlib/intern/scanfill.c
+++ b/source/blender/blenlib/intern/scanfill.c
@@ -865,7 +865,7 @@ unsigned int BLI_scanfill_calc_ex(ScanFillContext *sf_ctx, const int flag, const
 			/* Newell's Method */
 			/* Similar code used elsewhere, but this checks for double ups
 			 * which historically this function supports so better not change */
-			float *v_prev;
+			const float *v_prev;
 
 			zero_v3(n);
 			eve = sf_ctx->fillvertbase.last;
diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c
index bbc1354..892bb16 100644
--- a/source/blender/blenlib/intern/string.c
+++ b/source/blender/blenlib/intern/string.c
@@ -289,7 +289,7 @@ escape_finish:
 char *BLI_str_quoted_substrN(const char *__restrict str, const char *__restrict prefix)
 {
 	size_t prefixLen = strlen(prefix);
-	char *startMatch, *endMatch;
+	const char *startMatch, *endMatch;
 	
 	/* get the starting point (i.e. where prefix starts, and add prefixLen+1 to it to get be after the first " */
 	startMatch = strstr(str, prefix) + prefixLen + 1;
diff --git a/source/blender/blenlib/intern/string_utf8.c b/source/blender/blenlib/intern/string_utf8.c
index be93326..74e979a 100644
--- a/source/blender/blenlib/intern/string_utf8.c
+++ b/source/blender/blenlib/intern/string_utf8.c
@@ -536,7 +536,7 @@ unsigned int BLI_str_utf8_as_unicode_step(const char *__restrict p, size_t *__re
 	if (UNLIKELY(len == -1)) {
 		/* when called with NULL end, result will never be NULL,
 		 * checks for a NULL character */
-		char *p_next = BLI_str_find_next_char_utf8(p, NULL);
+		const char *p_next = BLI_str_find_next_char_utf8(p, NULL);
 		/* will never return the same pointer unless '\0',
 		 * eternal loop is prevented */
 		*index += (size_t)(p_next - p);




More information about the Bf-blender-cvs mailing list