From 4d535bbe0390ed4f03c611e433145c9e49cbf3ad Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 9 Jul 2017 14:59:05 +0200 Subject: Add serd_node_from_substring() This allows creating nodes in-place from substrings of other strings to allow zero-copy serialization from existing delimited buffers. --- serd/serd.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'serd') diff --git a/serd/serd.h b/serd/serd.h index ca72a232..027c4e20 100644 --- a/serd/serd.h +++ b/serd/serd.h @@ -448,6 +448,16 @@ SERD_API SerdNode serd_node_from_string(SerdType type, const uint8_t* str); +/** + Make a (shallow) node from a prefix of `str`. + + This measures, but does not copy, `str`. No memory is allocated. + Note that the returned node may not be null terminated. +*/ +SERD_API +SerdNode +serd_node_from_substring(SerdType type, const uint8_t* str, size_t len); + /** Make a deep copy of `node`. -- cgit v1.2.1