[Bf-blender-cvs] [7ca74fc] master: Code cleanup: use 'const' for arrays (blenloader, gpu, imbuf, makesdna, modifiers, nodes)

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


Commit: 7ca74fc1c008355b84c08bcadb56ea6acabce2f3
Author: Campbell Barton
Date:   Sun Apr 27 00:24:11 2014 +1000
https://developer.blender.org/rB7ca74fc1c008355b84c08bcadb56ea6acabce2f3

Code cleanup: use 'const' for arrays (blenloader, gpu, imbuf, makesdna, modifiers, nodes)

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

M	source/blender/blenloader/intern/readblenentry.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/blenloader/intern/versioning_250.c
M	source/blender/blenloader/intern/writefile.c
M	source/blender/gpu/intern/gpu_buffers.c
M	source/blender/gpu/intern/gpu_draw.c
M	source/blender/gpu/intern/gpu_extensions.c
M	source/blender/imbuf/intern/colormanagement.c
M	source/blender/imbuf/intern/divers.c
M	source/blender/imbuf/intern/filter.c
M	source/blender/imbuf/intern/imageprocess.c
M	source/blender/imbuf/intern/iris.c
M	source/blender/imbuf/intern/scaling.c
M	source/blender/makesdna/intern/dna_genfile.c
M	source/blender/makesdna/intern/makesdna.c
M	source/blender/makesrna/intern/makesrna.c
M	source/blender/makesrna/intern/rna_access.c
M	source/blender/makesrna/intern/rna_define.c
M	source/blender/modifiers/intern/MOD_explode.c
M	source/blender/modifiers/intern/MOD_meshdeform.c
M	source/blender/modifiers/intern/MOD_screw.c
M	source/blender/nodes/shader/node_shader_util.c
M	source/blender/nodes/shader/nodes/node_shader_texture.c
M	source/blender/nodes/texture/nodes/node_texture_image.c
M	source/blender/nodes/texture/nodes/node_texture_output.c

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

diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c
index 5dcf875..c1590d0 100644
--- a/source/blender/blenloader/intern/readblenentry.c
+++ b/source/blender/blenloader/intern/readblenentry.c
@@ -102,8 +102,8 @@ void BLO_blendhandle_print_sizes(BlendHandle *bh, void *fp)
 		if (bhead->code == ENDB)
 			break;
 		else {
-			short *sp = fd->filesdna->structs[bhead->SDNAnr];
-			char *name = fd->filesdna->types[sp[0]];
+			const short *sp = fd->filesdna->structs[bhead->SDNAnr];
+			const char *name = fd->filesdna->types[sp[0]];
 			char buf[4];
 			
 			buf[0] = (bhead->code >> 24) & 0xFF;
@@ -131,7 +131,7 @@ LinkNode *BLO_blendhandle_get_datablock_names(BlendHandle *bh, int ofblocktype,
 
 	for (bhead = blo_firstbhead(fd); bhead; bhead = blo_nextbhead(fd, bhead)) {
 		if (bhead->code == ofblocktype) {
-			char *idname = bhead_id_name(fd, bhead);
+			const char *idname = bhead_id_name(fd, bhead);
 
 			BLI_linklist_prepend(&names, strdup(idname + 2));
 			tot++;
@@ -156,7 +156,7 @@ LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype, int *to
 
 	for (bhead = blo_firstbhead(fd); bhead; bhead = blo_nextbhead(fd, bhead)) {
 		if (bhead->code == ofblocktype) {
-			char *idname = bhead_id_name(fd, bhead);
+			const char *idname = bhead_id_name(fd, bhead);
 			switch (GS(idname)) {
 				case ID_MA: /* fall through */
 				case ID_TE: /* fall through */
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 2c97d98..004eacd 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -537,7 +537,7 @@ static Main *blo_find_main(FileData *fd, const char *filepath, const char *relab
 //	printf("blo_find_main: converted to %s\n", name1);
 	
 	for (m = mainlist->first; m; m = m->next) {
-		char *libname = (m->curlib) ? m->curlib->filepath : m->name;
+		const char *libname = (m->curlib) ? m->curlib->filepath : m->name;
 		
 		if (BLI_path_cmp(name1, libname) == 0) {
 			if (G.debug & G_DEBUG) printf("blo_find_main: found library %s\n", libname);
@@ -3052,7 +3052,7 @@ static void lib_link_key(FileData *fd, Main *main)
 static void switch_endian_keyblock(Key *key, KeyBlock *kb)
 {
 	int elemsize, a, b;
-	char *data, *poin, *cp;
+	const char *data, *poin, *cp;
 	
 	elemsize = key->elemsize;
 	data = kb->data;
@@ -4333,7 +4333,7 @@ static void lib_link_object(FileData *fd, Main *main)
 			/* When the object is local and the data is library its possible
 			 * the material list size gets out of sync. [#22663] */
 			if (ob->data && ob->id.lib != ((ID *)ob->data)->lib) {
-				short *totcol_data = give_totcolp(ob);
+				const short *totcol_data = give_totcolp(ob);
 				/* Only expand so as not to loose any object materials that might be set. */
 				if (totcol_data && (*totcol_data > ob->totcol)) {
 					/* printf("'%s' %d -> %d\n", ob->id.name, ob->totcol, *totcol_data); */
diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c
index 17600d1..e6d327f 100644
--- a/source/blender/blenloader/intern/versioning_250.c
+++ b/source/blender/blenloader/intern/versioning_250.c
@@ -1267,7 +1267,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
 		Lattice *lt;
 		Curve *cu;
 		Key *key;
-		float *data;
+		const float *data;
 		int a, tot;
 
 		/* shape keys are no longer applied to the mesh itself, but rather
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 71e490d..70e3c62 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -344,7 +344,7 @@ static int endwrite(WriteData *wd)
 static void writestruct_at_address(WriteData *wd, int filecode, const char *structname, int nr, void *adr, void *data)
 {
 	BHead bh;
-	short *sp;
+	const short *sp;
 
 	if (adr==NULL || data==NULL || nr==0) return;
 
@@ -1337,7 +1337,7 @@ static void write_pose(WriteData *wd, bPose *pose)
 
 	/* write IK param */
 	if (pose->ikparam) {
-		char *structname = (char *)BKE_pose_ikparam_get_name(pose);
+		const char *structname = (char *)BKE_pose_ikparam_get_name(pose);
 		if (structname)
 			writestruct(wd, DATA, structname, 1, pose->ikparam);
 	}
@@ -1784,7 +1784,7 @@ static void write_customdata(WriteData *wd, ID *id, int count, CustomData *data,
 			write_mdisps(wd, count, layer->data, layer->flag & CD_FLAG_EXTERNAL);
 		}
 		else if (layer->type == CD_PAINT_MASK) {
-			float *layer_data = layer->data;
+			const float *layer_data = layer->data;
 			writedata(wd, DATA, sizeof(*layer_data) * count, layer_data);
 		}
 		else if (layer->type == CD_GRID_PAINT_MASK) {
diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c
index 194ea2b..a30918a 100644
--- a/source/blender/gpu/intern/gpu_buffers.c
+++ b/source/blender/gpu/intern/gpu_buffers.c
@@ -736,7 +736,7 @@ static void GPU_buffer_copy_normal(DerivedMesh *dm, float *varray, int *index, i
 	int start;
 	float f_no[3];
 
-	float *nors = dm->getTessFaceDataArray(dm, CD_NORMAL);
+	const float *nors = dm->getTessFaceDataArray(dm, CD_NORMAL);
 	short (*tlnors)[4][3] = dm->getTessFaceDataArray(dm, CD_TESSLOOPNORMAL);
 	MVert *mvert = dm->getVertArray(dm);
 	MFace *f = dm->getTessFaceArray(dm);
@@ -1384,7 +1384,7 @@ struct GPU_PBVH_Buffers {
 	/* mesh pointers in case buffer allocation fails */
 	MFace *mface;
 	MVert *mvert;
-	int *face_indices;
+	const int *face_indices;
 	int totface;
 	const float *vmask;
 
@@ -1393,7 +1393,7 @@ struct GPU_PBVH_Buffers {
 	CCGElem **grids;
 	const DMFlagMat *grid_flag_mats;
 	BLI_bitmap * const *grid_hidden;
-	int *grid_indices;
+	const int *grid_indices;
 	int totgrid;
 	int has_hidden;
 
@@ -1908,7 +1908,7 @@ static GLuint gpu_get_grid_buffer(int gridsize, GLenum *index_type, unsigned *to
 
 	/* used in the FILL_QUAD_BUFFER macro */
 	BLI_bitmap * const *grid_hidden = NULL;
-	int *grid_indices = NULL;
+	const int *grid_indices = NULL;
 	int totgrid = 1;
 
 	/* VBO is disabled; delete the previous buffer (if it exists) and
@@ -2520,7 +2520,7 @@ void GPU_draw_pbvh_buffers(GPU_PBVH_Buffers *buffers, DMSetMaterial setMaterial,
 			glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
 
 		if (buffers->tot_quad) {
-			char *offset = 0;
+			const char *offset = 0;
 			int i, last = buffers->has_hidden ? 1 : buffers->totgrid;
 			for (i = 0; i < last; i++) {
 				glVertexPointer(3, GL_FLOAT, sizeof(VertexBufferFormat),
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c
index 97084f7..1845de1 100644
--- a/source/blender/gpu/intern/gpu_draw.c
+++ b/source/blender/gpu/intern/gpu_draw.c
@@ -85,7 +85,7 @@ extern Material defmaterial; /* from material.c */
 static void gpu_mcol(unsigned int ucol)
 {
 	/* mcol order is swapped */
-	char *cp= (char *)&ucol;
+	const char *cp= (char *)&ucol;
 	glColor3ub(cp[3], cp[2], cp[1]);
 }
 
diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c
index 5c3bf6e..cd256a5 100644
--- a/source/blender/gpu/intern/gpu_extensions.c
+++ b/source/blender/gpu/intern/gpu_extensions.c
@@ -330,7 +330,7 @@ struct GPUTexture {
 static unsigned char *GPU_texture_convert_pixels(int length, float *fpixels)
 {
 	unsigned char *pixels, *p;
-	float *fp;
+	const float *fp;
 	int a, len;
 
 	len = 4*length;
diff --git a/source/blender/imbuf/intern/colormanagement.c b/source/blender/imbuf/intern/colormanagement.c
index 8aa9615..50c44c2 100644
--- a/source/blender/imbuf/intern/colormanagement.c
+++ b/source/blender/imbuf/intern/colormanagement.c
@@ -1237,7 +1237,7 @@ const char *IMB_colormanagement_get_rect_colorspace(ImBuf *ibuf)
 typedef struct DisplayBufferThread {
 	ColormanageProcessor *cm_processor;
 
-	float *buffer;
+	const float *buffer;
 	unsigned char *byte_buffer;
 
 	float *display_buffer;
@@ -1258,7 +1258,7 @@ typedef struct DisplayBufferThread {
 typedef struct DisplayBufferInitData {
 	ImBuf *ibuf;
 	ColormanageProcessor *cm_processor;
-	float *buffer;
+	const float *buffer;
 	unsigned char *byte_buffer;
 
 	float *display_buffer;
diff --git a/source/blender/imbuf/intern/divers.c b/source/blender/imbuf/intern/divers.c
index 0bd5c5c..f896d97 100644
--- a/source/blender/imbuf/intern/divers.c
+++ b/source/blender/imbuf/intern/divers.c
@@ -567,7 +567,7 @@ void IMB_rect_from_float(ImBuf *ibuf)
 /* converts from linear float to sRGB byte for part of the texture, buffer will hold the changed part */
 void IMB_partial_rect_from_float(ImBuf *ibuf, float *buffer, int x, int y, int w, int h, bool is_data)
 {
-	float *rect_float;
+	const float *rect_float;
 	uchar *rect_byte;
 	int profile_from = IB_PROFILE_LINEAR_RGB;
 
diff --git a/source/blender/imbuf/intern/filter.c b/source/blender/imbuf/intern/filter.c
index c7491a0..352e230 100644
--- a/source/blender/imbuf/intern/filter.c
+++ b/source/blender/imbuf/intern/filter.c
@@ -263,7 +263,7 @@ void IMB_filter(struct ImBuf *ibuf)
 
 void IMB_mask_filter_extend(char *mask, int width, int height)
 {
-	char *row1, *row2, *row3;
+	const char *row1, *row2, *row3;
 	int rowlen, x, y;
 	char *temprect;
 
diff --git a/source/blender/imbuf/intern/imageprocess.c b/source/blender/imbuf/intern/imageprocess.c
index e0a6e03..4cdfc29 100644
--- a/source/blender/imbuf/intern/imageprocess.c
+++ b/source/blender/imbuf/intern/imageprocess.c
@@ -221,7 +221,7 @@ void bilinear_interpolation(ImBuf *in, ImBuf *out, float u, float v, int xout, i
 /* NEAREST INTERPOLATION */
 void nearest_interpolation_color(struct ImBuf *in, unsigned char outI[4], float outF[4], float u, float v)
 {
-	float *dataF;
+	const float *dataF;
 	unsigned char *dataI;
 	int y1, x1;
 
diff --git a/source/blender/imbuf/intern/iris.c b/source/blender/imbuf/intern/iris.c
index ac1bb24..8f98f24 100644
--- a/source/blender/imbuf/intern/iris.c
+++ b/source/blender/imbuf/intern/iris.c
@@ -72,7 +72,7 @@ typedef struct {
 	unsigned int    offset;
 	unsigned int    rleend;        /* for rle images */
 	unsigned int   *rowstart;  /* for rle images */
-	int            *rowsize;   /* for rle images */
+	const int            *rowsize;   /* for rle images

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list