[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [53069] trunk/blender/source/blender/ makesdna/intern/makesdna.c: patch [#33441] Remove unneeded strcpy()' s from makesdna.c

Campbell Barton ideasman42 at gmail.com
Mon Dec 17 03:46:34 CET 2012


Revision: 53069
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=53069
Author:   campbellbarton
Date:     2012-12-17 02:46:30 +0000 (Mon, 17 Dec 2012)
Log Message:
-----------
patch [#33441] Remove unneeded strcpy()'s from makesdna.c

Modified Paths:
--------------
    trunk/blender/source/blender/makesdna/intern/makesdna.c

Modified: trunk/blender/source/blender/makesdna/intern/makesdna.c
===================================================================
--- trunk/blender/source/blender/makesdna/intern/makesdna.c	2012-12-17 02:34:53 UTC (rev 53068)
+++ trunk/blender/source/blender/makesdna/intern/makesdna.c	2012-12-17 02:46:30 UTC (rev 53069)
@@ -208,7 +208,7 @@
 /**
  * Construct the DNA.c file
  */ 
-void dna_write(FILE *file, void *pntr, int size);
+static void dna_write(FILE *file, const void *pntr, const int size);
 
 /**
  * Report all structures found so far, and print their lengths.
@@ -892,7 +892,7 @@
 
 #define MAX_DNA_LINE_LENGTH 20
 
-void dna_write(FILE *file, void *pntr, int size)
+static void dna_write(FILE *file, const void *pntr, const int size)
 {
 	static int linelength = 0;
 	int i;
@@ -934,7 +934,7 @@
 }
 
 
-static int make_structDNA(char *baseDirectory, FILE *file)
+static int make_structDNA(const char *baseDirectory, FILE *file)
 {
 	int len, i;
 	short *sp;
@@ -1036,12 +1036,10 @@
 		/* pass */
 	}
 	else {
-		strcpy(str, "SDNA");
-		dna_write(file, str, 4);
+		dna_write(file, "SDNA", 4);
 		
 		/* write names */
-		strcpy(str, "NAME");
-		dna_write(file, str, 4);
+		dna_write(file, "NAME", 4);
 		len = nr_names;
 		dna_write(file, &len, 4);
 		
@@ -1053,8 +1051,7 @@
 		dna_write(file, names[0], len);
 		
 		/* write TYPES */
-		strcpy(str, "TYPE");
-		dna_write(file, str, 4);
+		dna_write(file, "TYPE", 4);
 		len = nr_types;
 		dna_write(file, &len, 4);
 	
@@ -1067,16 +1064,14 @@
 		dna_write(file, types[0], len);
 		
 		/* WRITE TYPELENGTHS */
-		strcpy(str, "TLEN");
-		dna_write(file, str, 4);
+		dna_write(file, "TLEN", 4);
 		
 		len = 2 * nr_types;
 		if (nr_types & 1) len += 2;
 		dna_write(file, typelens_native, len);
 		
 		/* WRITE STRUCTS */
-		strcpy(str, "STRC");
-		dna_write(file, str, 4);
+		dna_write(file, "STRC", 4);
 		len = nr_structs;
 		dna_write(file, &len, 4);
 	
@@ -1165,13 +1160,13 @@
 			return_status = 1;
 		}
 		else {
-			char baseDirectory[256];
+			const char *baseDirectory;
 
 			if (argc == 3) {
-				strcpy(baseDirectory, argv[2]);
+				baseDirectory = argv[2];
 			}
 			else {
-				strcpy(baseDirectory, BASE_HEADER);
+				baseDirectory = BASE_HEADER;
 			}
 
 			fprintf(file, "const unsigned char DNAstr[] = {\n");




More information about the Bf-blender-cvs mailing list