aboutsummaryrefslogtreecommitdiffstats
path: root/src/writer.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-02-21 01:37:29 +0000
committerDavid Robillard <d@drobilla.net>2012-02-21 01:37:29 +0000
commit62b72ec9b7dd20a9b676e958c4c17886b23d9ca7 (patch)
treed528ee19eef649e3a98ac99e5c0b68e482942672 /src/writer.c
parent99f6eefd3299b3a85ce773771331846d58fd83cf (diff)
downloadserd-62b72ec9b7dd20a9b676e958c4c17886b23d9ca7.tar.gz
serd-62b72ec9b7dd20a9b676e958c4c17886b23d9ca7.tar.bz2
serd-62b72ec9b7dd20a9b676e958c4c17886b23d9ca7.zip
Trim code.
git-svn-id: http://svn.drobilla.net/serd/trunk@317 490d8e77-9747-427b-9fa3-0b8f29cee8a0
Diffstat (limited to 'src/writer.c')
-rw-r--r--src/writer.c25
1 files changed, 9 insertions, 16 deletions
diff --git a/src/writer.c b/src/writer.c
index 2b94026c..5c99b366 100644
--- a/src/writer.c
+++ b/src/writer.c
@@ -109,18 +109,16 @@ anon_stack_top(SerdWriter* writer)
static void
copy_node(SerdNode* dst, const SerdNode* src)
{
- if (!src) {
- dst->type = SERD_NOTHING;
- return;
- }
- if (!dst->buf || dst->n_bytes < src->n_bytes) {
+ if (src) {
dst->buf = (uint8_t*)realloc((char*)dst->buf, src->n_bytes + 1);
+ dst->n_bytes = src->n_bytes;
+ dst->n_chars = src->n_chars;
+ dst->flags = src->flags;
+ dst->type = src->type;
+ memcpy((char*)dst->buf, src->buf, src->n_bytes + 1);
+ } else {
+ dst->type = SERD_NOTHING;
}
- dst->n_bytes = src->n_bytes;
- dst->n_chars = src->n_chars;
- dst->flags = src->flags;
- dst->type = src->type;
- memcpy((char*)dst->buf, src->buf, src->n_bytes + 1);
}
static inline size_t
@@ -426,12 +424,7 @@ write_node(SerdWriter* writer,
static inline bool
is_resource(const SerdNode* node)
{
- switch (node->type) {
- case SERD_URI: case SERD_CURIE: case SERD_BLANK:
- return true;
- default:
- return false;
- }
+ return node->type > SERD_LITERAL;
}
static void