This is the first time I am using python-list to interact with
comp.lang.python forum (because there are so many spam when using
browser to view it) so forgive me if something goes wrong.
Python already treat the returned buffer as 'bytes'. The problem is
Python don't know its size (or decides it wrong:-).
--Jach
Cameron Simpson at 2018/4/12 PM 02:28 wrote:
On 11Apr2018 21:16, jf...@ms4.hinet.net <jf...@ms4.hinet.net> wrote:
This C function returns a buffer which I declared it as a
ctypes.c_char_p. The buffer has size 0x10000 bytes long and the valid
data may vary from a few bytes to the whole size.
Could you show us the function?
In every call I know how much the valid data size is, but I suppose I
can't use slice to get it because there may be zero byte in it. What
to do?
Why not just return bytes? Allocate one of the correct size and copy the
bytes into it, then return?
Of course it is all hard to say without seeing some actual code.
Cheers,
Cameron Simpson <c...@cskk.id.au>
---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
--
https://mail.python.org/mailman/listinfo/python-list