Memory Management in Embedded Python

Huayang Xia huayang.xia at gmail.com
Thu Jan 18 13:11:06 EST 2007


Hi there,

I have a piece of code like this:

      void funct(PyObject* pyobj)
      {
         char   str[128];
         strncpy(str, "just a test string", sizeof(str));
         PyObject* pydata = PyObject_CallMethod(pyobj, "method_x",
"s", str);
         Py_DECREF(pydata);
      }

After the function is exited, the str is not there anymore. Will this
affect python operation. How does python use the str? It's copied or it
just uses the pointer?

Thanks in advance.




More information about the Python-list mailing list