How can I determine the used size/length of a buffer created with create_string_buffer?
buffer = create_string_buffer(1000)
e.g. in buffer I have 3 values and 997 unused -> how it’s possible to get the 3?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Is there any reason you can’t just do
len(buffer.value)?For pure theoretical fun of it — I see no reason to do this if you can use the above method — I’ll mention that you can also do
buffer.raw.find("\x00")orlist(buffer).index("\x00"). These fail if the string is not properly null-terminated though.