corrected error from commit r34810.
authorCampbell Barton <ideasman42@gmail.com>
Sun, 13 Feb 2011 13:07:12 +0000 (13:07 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 13 Feb 2011 13:07:12 +0000 (13:07 +0000)
source/blender/blenkernel/BKE_deform.h
source/blender/blenkernel/intern/deform.c
source/blender/editors/space_console/console_draw.c

index 52051712ff07ede1ea3b75ae150d113d7d28340c..eaabc57c781455208e320230178919eeef1faedd 100644 (file)
@@ -64,7 +64,7 @@ void defvert_normalize(struct MDeformVert *dvert);
 
 /* utility function, note that 32 chars is the maximum string length since its only
  * used with defgroups currently */
-void flip_side_name(char *name, const char *from_name, int strip_number);
+void flip_side_name(char name[32], const char from_name[32], int strip_number);
 
 #endif
 
index 7f51cfdc8b6760e54b78dfee3d89c2c167a3409f..7967013c2d4211b2929829684bdb2a22f076d4f8 100644 (file)
@@ -335,33 +335,34 @@ void defgroup_unique_name (bDeformGroup *dg, Object *ob)
 }
 
 /* finds the best possible flipped name. For renaming; check for unique names afterwards */
-/* if strip_number: removes number extensions */
-void flip_side_name (char *name, const char *from_name, int strip_number)
+/* if strip_number: removes number extensions
+ * note: dont use sizeof() for 'name' or 'from_name' */
+void flip_side_name (char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP_NAME], int strip_number)
 {
        int     len;
-       char    prefix[sizeof(((bDeformGroup *)NULL)->name)]=  "";   /* The part before the facing */
-       char    suffix[sizeof(((bDeformGroup *)NULL)->name)]=  "";   /* The part after the facing */
-       char    replace[sizeof(((bDeformGroup *)NULL)->name)]= "";   /* The replacement string */
-       char    number[sizeof(((bDeformGroup *)NULL)->name)]=  "";   /* The number extension string */
+       char    prefix[MAX_VGROUP_NAME]=  "";   /* The part before the facing */
+       char    suffix[MAX_VGROUP_NAME]=  "";   /* The part after the facing */
+       char    replace[MAX_VGROUP_NAME]= "";   /* The replacement string */
+       char    number[MAX_VGROUP_NAME]=  "";   /* The number extension string */
        char    *index=NULL;
 
-       len= strlen(from_name);
+       len= BLI_strnlen(from_name, MAX_VGROUP_NAME);
        if(len<3) return; // we don't do names like .R or .L
 
-       strcpy(name, from_name);
+       BLI_strncpy(name, from_name, MAX_VGROUP_NAME);
 
        /* We first check the case with a .### extension, let's find the last period */
        if(isdigit(name[len-1])) {
                index= strrchr(name, '.'); // last occurrence
                if (index && isdigit(index[1]) ) { // doesnt handle case bone.1abc2 correct..., whatever!
                        if(strip_number==0)
-                                strcpy(number, index);
+                                BLI_strncpy(number, index, sizeof(number));
                        *index= 0;
-                       len= strlen(name);
+                       len= BLI_strnlen(name, MAX_VGROUP_NAME);
                }
        }
 
-       strcpy(prefix, name);
+       BLI_strncpy(prefix, name, sizeof(prefix));
 
 #define IS_SEPARATOR(a) ((a)=='.' || (a)==' ' || (a)=='-' || (a)=='_')
 
@@ -445,7 +446,7 @@ void flip_side_name (char *name, const char *from_name, int strip_number)
 
 #undef IS_SEPARATOR
 
-       sprintf (name, "%s%s%s%s", prefix, replace, suffix, number);
+       BLI_snprintf (name, MAX_VGROUP_NAME, "%s%s%s%s", prefix, replace, suffix, number);
 }
 
 float defvert_find_weight(const struct MDeformVert *dvert, const int group_num)
index 3a19074bbb77cd1ce0a36cebcbadb55c839cc7d8..ba9993cfe60842e12831296e54468fd3de5d0f89 100644 (file)
@@ -193,7 +193,7 @@ static int console_textview_main__internal(struct SpaceConsole *sc, struct ARegi
        
        View2D *v2d= &ar->v2d;
 
-       TextViewContext tvc= {NULL};
+       TextViewContext tvc= {0};
 
        tvc.begin= console_textview_begin;
        tvc.end= console_textview_end;