tests CHANGE extend tests of default values in schemas
Covers deviating the default values and their types. Also fixes several
bugs in schema compilation and built-in data type plugins.
diff --git a/src/tree_schema.c b/src/tree_schema.c
index 24e38b3..61ca70e 100644
--- a/src/tree_schema.c
+++ b/src/tree_schema.c
@@ -216,8 +216,10 @@
return NULL;
}
+
+
API char *
-lysc_path(struct lysc_node *node, LY_PATH_TYPE pathtype)
+lysc_path(struct lysc_node *node, LY_PATH_TYPE pathtype, char *buffer, size_t buflen)
{
struct lysc_node *iter;
char *path = NULL;
@@ -226,7 +228,7 @@
switch (pathtype) {
case LY_PATH_LOG:
for (iter = node; iter && len >= 0; iter = iter->parent) {
- char *s = path;
+ char *s = buffer ? strdup(buffer) : path;
char *id;
switch (iter->nodetype) {
@@ -246,13 +248,26 @@
if (!iter->parent || iter->parent->module != iter->module) {
/* print prefix */
- len = asprintf(&path, "/%s:%s%s", iter->module->name, id, s ? s : "");
+ if (buffer) {
+ len = snprintf(buffer, buflen, "/%s:%s%s", iter->module->name, id, s ? s : "");
+ } else {
+ len = asprintf(&path, "/%s:%s%s", iter->module->name, id, s ? s : "");
+ }
} else {
/* prefix is the same as in parent */
- len = asprintf(&path, "/%s%s", id, s ? s : "");
+ if (buffer) {
+ len = snprintf(buffer, buflen, "/%s%s", id, s ? s : "");
+ } else {
+ len = asprintf(&path, "/%s%s", id, s ? s : "");
+ }
}
free(s);
free(id);
+
+ if (buffer && buflen <= (size_t)len) {
+ /* not enough space in buffer */
+ break;
+ }
}
if (len < 0) {
@@ -265,7 +280,11 @@
break;
}
- return path;
+ if (buffer) {
+ return buffer;
+ } else {
+ return path;
+ }
}
API int