diff options
author | David Robillard <d@drobilla.net> | 2011-04-24 00:49:35 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2011-04-24 00:49:35 +0000 |
commit | 0b04f70d827a850ca5e779819095766194cd0e94 (patch) | |
tree | ef44ac656c1f2a8f4687fe6ef5bdb594c30c156d /src/node.c | |
parent | 2824ef300111f198132de215b57376587851cbd7 (diff) | |
download | serd-0b04f70d827a850ca5e779819095766194cd0e94.tar.gz serd-0b04f70d827a850ca5e779819095766194cd0e94.tar.bz2 serd-0b04f70d827a850ca5e779819095766194cd0e94.zip |
Fix reader memory stack use and verify read_object fully clears its stack.
Make abbreviation in writer not assume equivalent nodes have equivalent addresses (abbreviate more than on input if triples are sorted correctly, e.g. abbrevate ntriples)
git-svn-id: http://svn.drobilla.net/serd/trunk@149 490d8e77-9747-427b-9fa3-0b8f29cee8a0
Diffstat (limited to 'src/node.c')
-rw-r--r-- | src/node.c | 20 |
1 files changed, 17 insertions, 3 deletions
@@ -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) { |