As rule of thumb I would say:
- use struct blob_buf b = {0}; in the function as local variable
- free after using it
- use "struct ubus_context *ctx_local" in callback functions to differentiate between global ctx pointer and local callback variables

In the examples it is also freed. However, I would move the global definitions to local ones?
https://git.openwrt.org/?p=project/libubox.git;a=blob;f=examples/json_script-example.c;h=6d93059a412e3c829c29df1b41c9dece8852499d;hb=HEAD#l10

Bests
Nick

On 10/13/21 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?

Bests
Nick


_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to