Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Ewering <blender@instinctive.de>2005-12-24 01:16:33 +0300
committerAlexander Ewering <blender@instinctive.de>2005-12-24 01:16:33 +0300
commit6f10660f0c47a76bf8e620701a39e7697eac7654 (patch)
treedc38df3af7bd64725dd0d2c0cdd3519cf34c6cc2 /source/blender/python/api2_2x/Armature.c
parente8f7ff2ffb03bae3ef64163f55e7b9247916d329 (diff)
Fixing a bit of horrible code in Armature.c (BonesDict_repr).
There is a lot of very dangerous (and slow) string manipulation code in there. I do not want to appear arrogant, but a bit of basic code QA in this module certainly can't hurt. Please see the diff for further explanation ;-)
Diffstat (limited to 'source/blender/python/api2_2x/Armature.c')
-rw-r--r--source/blender/python/api2_2x/Armature.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/source/blender/python/api2_2x/Armature.c b/source/blender/python/api2_2x/Armature.c
index d732ad38d71..2154b28988a 100644
--- a/source/blender/python/api2_2x/Armature.c
+++ b/source/blender/python/api2_2x/Armature.c
@@ -172,28 +172,25 @@ static int BonesDict_InitEditBones(BPy_BonesDict *self)
//This is the string representation of the object
static PyObject *BonesDict_repr(BPy_BonesDict *self)
{
- char buffer[128], str[4096];
+ char str[4096];
PyObject *key, *value;
int pos = 0;
+ char *p = str;
+
+ p += sprintf(str, "[Bone Dict: {");
- BLI_strncpy(str,"",4096);
- sprintf(buffer, "[Bone Dict: {");
- strcat(str,buffer);
if (self->editmode_flag){
while (PyDict_Next(self->editbonesMap, &pos, &key, &value)) {
- sprintf(buffer, "%s : %s, ", PyString_AsString(key),
+ p += sprintf(p, "%s : %s, ", PyString_AsString(key),
PyString_AsString(value->ob_type->tp_repr(value)));
- strcat(str,buffer);
}
}else{
while (PyDict_Next(self->bonesMap, &pos, &key, &value)) {
- sprintf(buffer, "%s : %s, ", PyString_AsString(key),
+ p += sprintf(p, "%s : %s, ", PyString_AsString(key),
PyString_AsString(value->ob_type->tp_repr(value)));
- strcat(str,buffer);
}
}
- sprintf(buffer, "}]\n");
- strcat(str,buffer);
+ p += sprintf(p, "}]\n");
return PyString_FromString(str);
}