diff options
author | David Robillard <d@drobilla.net> | 2011-05-12 16:46:29 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2011-05-12 16:46:29 +0000 |
commit | bc42e1c4d4fc93592b7e08226192acc00ccf37bc (patch) | |
tree | e97b59d0c982c42317a8eebd1851d69a2f85879c /src/node.c | |
parent | 13a66cb43bcab491f6ae7e1280b035b2522496c8 (diff) | |
download | serd-bc42e1c4d4fc93592b7e08226192acc00ccf37bc.tar.gz serd-bc42e1c4d4fc93592b7e08226192acc00ccf37bc.tar.bz2 serd-bc42e1c4d4fc93592b7e08226192acc00ccf37bc.zip |
Use conventional string lengths not including NULL terminator
git-svn-id: http://svn.drobilla.net/serd/trunk@174 490d8e77-9747-427b-9fa3-0b8f29cee8a0
Diffstat (limited to 'src/node.c')
-rw-r--r-- | src/node.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -40,7 +40,7 @@ serd_strlen(const uint8_t* str, size_t* n_bytes, SerdNodeFlags* flags) } } if (n_bytes) { - *n_bytes = i + 1; + *n_bytes = i; } return n_chars; } @@ -65,8 +65,8 @@ serd_node_copy(const SerdNode* node) } SerdNode copy = *node; - uint8_t* buf = malloc(copy.n_bytes); - memcpy(buf, node->buf, copy.n_bytes); + uint8_t* buf = malloc(copy.n_bytes + 1); + memcpy(buf, node->buf, copy.n_bytes + 1); copy.buf = buf; return copy; } @@ -147,13 +147,13 @@ serd_node_new_uri(const SerdURI* uri, const SerdURI* base, SerdURI* out) const size_t len = serd_uri_string_length(&abs_uri); uint8_t* buf = malloc(len + 1); - SerdNode node = { buf, len + 1, len, 0, SERD_URI }; // FIXME: UTF-8 + SerdNode node = { buf, len, len, 0, SERD_URI }; // FIXME: UTF-8 uint8_t* ptr = buf; const size_t actual_len = serd_uri_serialise(&abs_uri, string_sink, &ptr); buf[actual_len] = '\0'; - node.n_bytes = actual_len + 1; + node.n_bytes = actual_len; node.n_chars = actual_len; // FIXME: double parse |