#endif
}
-inline char * str2charp_size(PyObject* pyObj, int * size)
+char * str2charp_size(PyObject* pyObj, int * size)
{
char * v_ = 0;
+ Py_ssize_t len = 0;
#if PY_MAJOR_VERSION >= 3
- PyBytes_AsStringAndSize(pyObj, &v_, (Py_ssize_t*)size);
+ PyBytes_AsStringAndSize(pyObj, &v_, &len);
#else
- PyString_AsStringAndSize(pyObj, &v_, (Py_ssize_t*)size);
+ PyString_AsStringAndSize(pyObj, &v_, &len);
#endif
+ *size = len;
return v_;
}
%}
%enddef
%feature("autodoc", ftdi_read_data_docstring) ftdi_read_data;
%typemap(in,numinputs=1) (unsigned char *buf, int size) %{ $2 = PyInt_AsLong($input);$1 = (unsigned char*)malloc($2*sizeof(char)); %}
-%typemap(argout) (unsigned char *buf, int size) %{ if(result<0) $2=0; $result = SWIG_Python_AppendOutput($result, charp2str((char*)$1, $2)); free($1); %}
+%typemap(argout) (unsigned char *buf, int size) %{
+ if(result<0)
+ $2=0;
+ $result = SWIG_Python_AppendOutput($result, charp2str((char*)$1, $2));
+ free($1);
+%}
int ftdi_read_data(struct ftdi_context *ftdi, unsigned char *buf, int size);
%clear (unsigned char *buf, int size);
%clear int* value;
%typemap(in,numinputs=1) (unsigned char *buf, int size) %{ $2 = PyInt_AsLong($input);$1 = (unsigned char*)malloc($2*sizeof(char)); %}
-%typemap(argout) (unsigned char *buf, int size) %{ if(result<0) $2=0; $result = SWIG_Python_AppendOutput($result, charp2str((char*)$1, $2)); free($1); %}
+%typemap(argout) (unsigned char *buf, int size) %{
+ if(result<0)
+ $2=0;
+ $result = SWIG_Python_AppendOutput($result, charp2str((char*)$1, $2));
+ free($1);
+%}
int ftdi_get_eeprom_buf(struct ftdi_context *ftdi, unsigned char * buf, int size);
%clear (unsigned char *buf, int size);