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:
authorKen Hughes <khughes@pacific.edu>2005-11-08 21:46:55 +0300
committerKen Hughes <khughes@pacific.edu>2005-11-08 21:46:55 +0300
commitc217188a626dac22988fb87dbeb906fd12c3a925 (patch)
tree6a31ae2e04a03eabfcafd1506e2a800025fbb37b /source/blender/python/api2_2x/constant.c
parent19b75ae86deafe23475eebba2af51bcf6865ba5b (diff)
-- Previous commit using PyDict_Keys left new reference around. Change to use
PyDict_GetItem() instead, and clean up string manipulation.
Diffstat (limited to 'source/blender/python/api2_2x/constant.c')
-rw-r--r--source/blender/python/api2_2x/constant.c33
1 files changed, 13 insertions, 20 deletions
diff --git a/source/blender/python/api2_2x/constant.c b/source/blender/python/api2_2x/constant.c
index f131a169089..76c539be545 100644
--- a/source/blender/python/api2_2x/constant.c
+++ b/source/blender/python/api2_2x/constant.c
@@ -135,31 +135,24 @@ static PyObject *constant_getAttr(BPy_constant * self, char *name)
//------------------------tp_repr
static PyObject *constant_repr(BPy_constant * self)
{
- char buffer[128], str[4096];
- PyObject *key, *value, *keys;
+ char str[4096];
+ PyObject *key, *value;
int pos = 0;
- BLI_strncpy(str,"",4096);
- sprintf(buffer, "[Constant: ");
- strcat(str,buffer);
- keys = PyDict_Keys(self->dict);
- if (PySequence_Contains(keys, PyString_FromString("name"))){
- value = PyDict_GetItemString(self->dict, "name");
- sprintf(buffer, "%s", PyString_AsString(value));
- strcat(str,buffer);
- }else{
- sprintf(buffer, "{");
- strcat(str,buffer);
- memset(buffer,0,128);
+ BLI_strncpy(str,"[Constant: ",4096);
+ value = PyDict_GetItem( self->dict, PyString_FromString("name") );
+ if(value) {
+ strcat(str, PyString_AsString(value));
+ } else {
+ strcat(str,"{");
while (PyDict_Next(self->dict, &pos, &key, &value)) {
- strcat(str,buffer);
- sprintf(buffer, "%s, ", PyString_AsString(key));
+ strcat (str, PyString_AsString(key));
+ strcat (str, ", ");
}
- sprintf(buffer, "%s}", PyString_AsString(key));
- strcat(str,buffer);
+ strcat(str, PyString_AsString(key));
+ strcat(str,"}");
}
- sprintf(buffer, "]");
- strcat(str,buffer);
+ strcat(str, "]");
return PyString_FromString(str);
}
//------------------------tp_dealloc