Change constness of the data returned by module implementation callbacks
libyang itself won't modify these data, so a `const char *` is a better
match. That will allow returning, e.g., string literals or C++'s
`std::string::c_str` without any extra deleter.
The cost of this patch is an extra cast which is needed when calling a
deleter. If a deleter is used, then quite obviously that data cannot be
const.
diff --git a/src/context.c b/src/context.c
index 54c516e..9acc91c 100644
--- a/src/context.c
+++ b/src/context.c
@@ -902,7 +902,7 @@
int implement, struct unres_schema *unres)
{
struct lys_module *mod = NULL;
- char *module_data = NULL;
+ const char *module_data = NULL;
LYS_INFORMAT format = LYS_IN_UNKNOWN;
void (*module_data_free)(void *module_data, void *user_data) = NULL;
@@ -928,7 +928,7 @@
}
if (module_data_free) {
- module_data_free(module_data, ctx->imp_clb_data);
+ module_data_free((char *)module_data, ctx->imp_clb_data);
}
}