aboutsummaryrefslogtreecommitdiffstats
path: root/src/node.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/node.c')
-rw-r--r--src/node.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/node.c b/src/node.c
index 5901f159..173c5358 100644
--- a/src/node.c
+++ b/src/node.c
@@ -34,12 +34,26 @@ SerdNode
serd_node_copy(const SerdNode* node)
{
SerdNode copy = *node;
- uint8_t* buf = malloc(copy.n_bytes);
- memcpy(buf, node->buf, copy.n_bytes);
- copy.buf = buf;
+ if (node->buf) {
+ uint8_t* buf = malloc(copy.n_bytes);
+ memcpy(buf, node->buf, copy.n_bytes);
+ copy.buf = buf;
+ }
return copy;
}
+SERD_API
+bool
+serd_node_equals(const SerdNode* a, const SerdNode* b)
+{
+ return (a == b)
+ || (a->type == b->type
+ && a->n_bytes == b->n_bytes
+ && a->n_chars == b->n_chars
+ && ((a->buf == b->buf) || !strcmp((const char*)a->buf,
+ (const char*)b->buf)));
+}
+
static size_t
serd_uri_string_length(const SerdURI* uri)
{