handling of blob_buf_free?

Nick vincent at systemli.org
Wed Oct 13 02:32:39 PDT 2021


Does it make a difference in terms of performance to use stack buffers?
I switched now to using stack buffers, since for me it makes the code 
more readable not having to deal with several buffers and possible race 
conditions. (but just my view on the topic)

Thanks a lot for your answer. I will also update the forum post with the 
information! :)

Bests
Nick

On 10/13/21 10:51, Felix Fietkau wrote:
> On 2021-10-13 07:53, Nick wrote:
>> Since I saw there were some new patches, e.g., procd, fixing
>> blob_buf_free() calls.
>> I asked several months ago: "Should you call blob_buf_free() after
>> calling blob_buf_init()?"
>> https://forum.openwrt.org/t/should-you-call-blob-buf-free-after-calling-blob-buf-init
>>
>> I did not receive any answer. I think blob_buf_init() is freeing memory
>> if it is the same buf?
>> Any suggestions how to use blob_buf_free?
> If a buffer was already allocated, blob_buf_init reuses it. You can keep
> reusing it as many times as you want. You only need to call
> blob_buf_free if you explicitly want to free the buffer memory (e.g. on
> exit, or if the blob_buf is on stack)
>
> - Felix



More information about the openwrt-devel mailing list