Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

create_string_buffer how to get used size

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?

like image 695
leon22 Avatar asked May 02 '26 22:05

leon22


1 Answers

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") or list(buffer).index("\x00"). These fail if the string is not properly null-terminated though.

like image 139
Lauritz V. Thaulow Avatar answered May 04 '26 10:05

Lauritz V. Thaulow



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!