Re: [pypy-dev] How to convert python string to C char*?

2015-05-14 Thread Armin Rigo
Hi Yicong, (CC to the cffi mailing list) On 14 May 2015 at 05:02, Yicong Huang hengha@gmail.com wrote: We had a python function that return a string value. The function will callback in C code. The below is an example of the code: @ffi.callback(char *(char *, char *)) def strconcat(x,

Re: [pypy-dev] How to convert python string to C char*?

2015-05-14 Thread Yicong Huang
Thanks, the method did work. To my understanding, ALL_RESULTS is used to prevent pypy GC the pointing buffer. And thus, it is the C callback function's responsibility to free the buffer. Am I right? On Thu, May 14, 2015 at 4:13 PM, Armin Rigo ar...@tunes.org wrote: Hi Yicong, (CC to the

Re: [pypy-dev] How to convert python string to C char*?

2015-05-14 Thread Yicong Huang
Thanks, the method did work. To my understanding, ALL_RESULTS is used to prevent pypy GC the pointing buffer. And thus, it is the C callback function's responsibility to free the buffer. Am I right? On Thursday, May 14, 2015 at 4:14:07 PM UTC+8, Armin Rigo wrote: Hi Yicong, (CC to the

Re: [pypy-dev] How to convert python string to C char*?

2015-05-14 Thread Armin Rigo
Hi Yicong, On 14 May 2015 at 11:33, Yicong Huang hengha@gmail.com wrote: To my understanding, ALL_RESULTS is used to prevent pypy GC the pointing buffer. And thus, it is the C callback function's responsibility to free the buffer. Am I right? No. In my example I just keep storing

[pypy-dev] How to convert python string to C char*?

2015-05-13 Thread Yicong Huang
We had a python function that return a string value. The function will callback in C code. The below is an example of the code: @ffi.callback(char *(char *, char *)) def strconcat(x, y): x1 = ffi.string(x) y1 = ffi.string(y) print x1 + y1 return x1 + y1 The error messages are: