MCPcopy Create free account
hub / github.com/chokkan/crfsuite / SWIG_Python_str_AsChar

Function SWIG_Python_str_AsChar

swig/python/export_wrap.cpp:788–804  ·  view source on GitHub ↗

Warning: This function will allocate a new string in Python 3, * so please call SWIG_Python_str_DelForPy3(x) to free the space. */

Source from the content-addressed store, hash-verified

786 * so please call SWIG_Python_str_DelForPy3(x) to free the space.
787 */
788SWIGINTERN char*
789SWIG_Python_str_AsChar(PyObject *str)
790{
791#if PY_VERSION_HEX >= 0x03000000
792 char *cstr;
793 char *newstr;
794 Py_ssize_t len;
795 str = PyUnicode_AsUTF8String(str);
796 PyBytes_AsStringAndSize(str, &cstr, &len);
797 newstr = (char *) malloc(len+1);
798 memcpy(newstr, cstr, len+1);
799 Py_XDECREF(str);
800 return newstr;
801#else
802 return PyString_AsString(str);
803#endif
804}
805
806#if PY_VERSION_HEX >= 0x03000000
807# define SWIG_Python_str_DelForPy3(x) free( (void*) (x) )

Callers 6

SWIG_Python_AddErrorMsgFunction · 0.85
SwigPyObject_printFunction · 0.85
SWIG_Python_AddErrMesgFunction · 0.85
SWIG_Python_TypeErrorFunction · 0.85
export_wrap.cppFile · 0.85
swig_varlink_printFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected