From 62b72ec9b7dd20a9b676e958c4c17886b23d9ca7 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 21 Feb 2012 01:37:29 +0000 Subject: Trim code. git-svn-id: http://svn.drobilla.net/serd/trunk@317 490d8e77-9747-427b-9fa3-0b8f29cee8a0 --- src/writer.c | 25 +++++++++---------------- 1 file 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 -- cgit v1.2.1