Confd_data_reply_value function

Hello everyone,

I am so confused for the confd_data_reply_value function. Do I need free the memory for the following code?

confd_value_t myval;
CONFD_SET_STR(&myval, “test”);
confd_data_reply_value(tctx, &myval);
confd_free_value(&myval); ------------Is it required?

I assume that the function CONFD_SET_STR will malloc the memory for myval, If we call the confd_data_reply_value. I think we should free the memory. Am I right?

Thank you so much.

Short answer: No. Long answer:

None of the CONFD_SET_XXX() macros will malloc() (or free()) anything. None of the confd_data_reply_xxx() functions will malloc() memory that the the application will need to free(), nor free() memory for data that the application passes to the function. All the application needs to do is make sure that the data passed to confd_data_reply_xxx() is valid for the duration of the call. I.e. if the application malloc()ed memory for the data, it will need to free() that memory when the confd_data_reply_xxx() call has completed, otherwise not.

Also, if you check the documentation for confd_free_value() in the confd_lib_lib(3) manual page, it starts by enumerating the cases where the function needs to be used.

Thank you for your reply. I checked the macro from confd_lib.h file. The CONFD_SET_XXX() function do not malloc the memory.

Best Regards,
Hanosn Diao