I'm using libuci in my C application, and am parsing some configuration files periodically. The question is that is there any need for calling free() to stop memory leak after uci_lookup_ptr() call? I tested with valgrind, but I'm not sure I didn't introduce memory leak.
Hi, the memory used for reading configs etc. is managed by the uci context you pass to each function. The uci_lookup_ptr() call does not explicitly allocate memory by itself but it might implicitly load configuration files through uci_load().
Config files are loaded only once per context though, so there will be no leak by frequently doing lookups. To free all data associated with a context, including the context itself, use uci_free_context(). To explicitly unload single configurations from the context, use uci_unload().
To enumerate currently loaded configs in the context, use something like this: