aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-02-03 03:08:43 +0000
committerDavid Robillard <d@drobilla.net>2011-02-03 03:08:43 +0000
commit051f8e0bfdd0083f152197e1da6db70af0bb9793 (patch)
treedfbd934681fd714696a29f0d2ac9f2be9886f03f
parent787af7fe07b00057b7d886e9fd508b259914997d (diff)
downloadserd-051f8e0bfdd0083f152197e1da6db70af0bb9793.tar.gz
serd-051f8e0bfdd0083f152197e1da6db70af0bb9793.tar.bz2
serd-051f8e0bfdd0083f152197e1da6db70af0bb9793.zip
Add serd_node_from_string.
git-svn-id: http://svn.drobilla.net/serd/trunk@90 490d8e77-9747-427b-9fa3-0b8f29cee8a0
-rw-r--r--serd/serd.h7
-rw-r--r--src/node.c10
2 files changed, 17 insertions, 0 deletions
diff --git a/serd/serd.h b/serd/serd.h
index c19b3b3a..0b90cde7 100644
--- a/serd/serd.h
+++ b/serd/serd.h
@@ -176,6 +176,13 @@ typedef struct {
static const SerdNode SERD_NODE_NULL = { SERD_NOTHING, 0, 0, 0 };
+/** Make a (shallow) node from @a str.
+ * This measures, but does not copy, @a str. No memory is allocated.
+ */
+SERD_API
+SerdNode
+serd_node_from_string(SerdType type, const uint8_t* str);
+
/** Make a deep copy of @a node.
* @return a node that the caller must free with @ref serd_node_free.
*/
diff --git a/src/node.c b/src/node.c
index 0b306489..66e5b5c1 100644
--- a/src/node.c
+++ b/src/node.c
@@ -24,6 +24,16 @@
SERD_API
SerdNode
+serd_node_from_string(SerdType type, const uint8_t* buf)
+{
+ size_t buf_n_bytes;
+ const size_t buf_n_chars = serd_strlen(buf, &buf_n_bytes);
+ SerdNode ret = { type, buf_n_bytes, buf_n_chars, buf };
+ return ret;
+}
+
+SERD_API
+SerdNode
serd_node_copy(const SerdNode* node)
{
SerdNode copy = *node;