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
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
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
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