diff options
author | David Robillard <d@drobilla.net> | 2011-01-24 21:11:53 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2011-01-24 21:11:53 +0000 |
commit | 6903e56e2443a1a5b023d688cb7fd54e3580316d (patch) | |
tree | 291d35f268ed8de8ed1a671800d3481003abc4dc /src/string.c | |
parent | cffc0e7bb7a52153673d3eba2e31d6b2930a6248 (diff) | |
download | serd-6903e56e2443a1a5b023d688cb7fd54e3580316d.tar.gz serd-6903e56e2443a1a5b023d688cb7fd54e3580316d.tar.bz2 serd-6903e56e2443a1a5b023d688cb7fd54e3580316d.zip |
Remove SerdString from public API in favour of more expressive (and not necessarily inline with data payload) SerdNode.
git-svn-id: http://svn.drobilla.net/serd/trunk@53 490d8e77-9747-427b-9fa3-0b8f29cee8a0
Diffstat (limited to 'src/string.c')
-rw-r--r-- | src/string.c | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/src/string.c b/src/string.c index 0f5d2430..77346676 100644 --- a/src/string.c +++ b/src/string.c @@ -8,11 +8,11 @@ * * Serd is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for details. * * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. + * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <assert.h> @@ -20,8 +20,9 @@ #include <stdlib.h> #include <string.h> -#include "serd/serd.h" +#include "serd_internal.h" +#if 0 static inline size_t utf8_strlen(const uint8_t* utf8, size_t* out_n_bytes) { @@ -38,20 +39,37 @@ utf8_strlen(const uint8_t* utf8, size_t* out_n_bytes) } return n_chars; } +#endif +static SerdString* +serd_string_new_measured(const uint8_t* utf8, size_t n_bytes, size_t n_chars) +{ + SerdString* const str = malloc(sizeof(SerdString) + n_bytes); + str->n_bytes = n_bytes; + str->n_chars = n_chars; + memcpy(str->buf, utf8, n_bytes); + return str; +} + +#if 0 SERD_API SerdString* serd_string_new(const uint8_t* utf8) { size_t n_bytes; size_t n_chars = utf8_strlen(utf8, &n_bytes); - SerdString* const str = malloc(sizeof(SerdString) + n_bytes); - str->n_bytes = n_bytes; - str->n_chars = n_chars; - memcpy(str->buf, utf8, str->n_bytes); - return str; + return serd_string_new_measured(utf8, n_bytes, n_chars); +} +#endif + +SERD_API +SerdString* +serd_string_new_from_node(const SerdNode* node) +{ + return serd_string_new_measured(node->buf, node->n_bytes, node->n_chars); } +#if 0 SERD_API SerdString* serd_string_copy(const SerdString* s) @@ -63,6 +81,7 @@ serd_string_copy(const SerdString* s) } return NULL; } +#endif SERD_API void |