Re: Question about PyDict_SetItemString

2007-07-13 Thread Hrvoje Niksic
lgx <[EMAIL PROTECTED]> writes: >From Google results, I find some source code write like that. But >some code write like below: > > obj = PyString_FromString("value"); > PyDict_SetItemString(pDict,"key",obj); > Py_DECREF(obj); > > So, which one is correct? The latter is correct. While PyDict_Ge

Re: Question about PyDict_SetItemString

2007-07-13 Thread Stefan Behnel
lgx schrieb: > Does PyDict_SetItemString(pDict,"key",PyString_FromString("value")) > cause memory leak? > >>From Google results, I find some source code write like that. But some > code write like below: > > obj = PyString_FromString("value"); > PyDict_SetItemString(pDict,"key",obj); > Py_DECREF

Re: Question about PyDict_SetItemString

2007-07-13 Thread Stefan Behnel
lgx schrieb: > Does PyDict_SetItemString(pDict,"key",PyString_FromString("value")) > cause memory leak? You shouldn't use that at all. If you look at the sources, what SetItemString does is: create a Python string from the char* and call PyDict_SetItem() to put the new string in. So it is actually

Question about PyDict_SetItemString

2007-07-13 Thread lgx
Does PyDict_SetItemString(pDict,"key",PyString_FromString("value")) cause memory leak? >From Google results, I find some source code write like that. But some code write like below: obj = PyString_FromString("value"); PyDict_SetItemString(pDict,"key",obj); Py_DECREF(obj); So, which one is corre