handling of blob_buf_free?

Felix Fietkau nbd at nbd.name
Wed Oct 13 01:51:29 PDT 2021


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