aboutsummaryrefslogtreecommitdiffstats
path: root/src/env.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2016-03-16 16:21:20 -0400
committerDavid Robillard <d@drobilla.net>2021-03-07 15:32:23 -0500
commita29581d3ba664175c459e20e6c86be09707fde6e (patch)
treed11253ca88b09d7a768740b00332a4d780e3852d /src/env.c
parent6e856d3e7a9c3162b9af350d5cec8a3f6bb94ee2 (diff)
downloadserd-a29581d3ba664175c459e20e6c86be09707fde6e.tar.gz
serd-a29581d3ba664175c459e20e6c86be09707fde6e.tar.bz2
serd-a29581d3ba664175c459e20e6c86be09707fde6e.zip
Use char* for strings in public API
The constant casting just makes user code a mess, for no benefit.
Diffstat (limited to 'src/env.c')
-rw-r--r--src/env.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/env.c b/src/env.c
index 05274df6..9d4721d2 100644
--- a/src/env.c
+++ b/src/env.c
@@ -17,7 +17,6 @@
#include "serd/serd.h"
#include <stdbool.h>
-#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -100,7 +99,7 @@ serd_env_set_base_uri(SerdEnv* env, const SerdNode* uri)
}
static inline SERD_PURE_FUNC SerdPrefix*
-serd_env_find(const SerdEnv* env, const uint8_t* name, size_t name_len)
+serd_env_find(const SerdEnv* env, const char* name, size_t name_len)
{
for (size_t i = 0; i < env->n_prefixes; ++i) {
const SerdNode* const prefix_name = &env->prefixes[i].name;
@@ -157,9 +156,9 @@ serd_env_set_prefix(SerdEnv* env, const SerdNode* name, const SerdNode* uri)
}
SerdStatus
-serd_env_set_prefix_from_strings(SerdEnv* env,
- const uint8_t* name,
- const uint8_t* uri)
+serd_env_set_prefix_from_strings(SerdEnv* env,
+ const char* name,
+ const char* uri)
{
const SerdNode name_node = serd_node_from_string(SERD_LITERAL, name);
const SerdNode uri_node = serd_node_from_string(SERD_URI, uri);
@@ -176,9 +175,7 @@ serd_env_qualify(const SerdEnv* env,
for (size_t i = 0; i < env->n_prefixes; ++i) {
const SerdNode* const prefix_uri = &env->prefixes[i].uri;
if (uri->n_bytes >= prefix_uri->n_bytes) {
- if (!strncmp((const char*)uri->buf,
- (const char*)prefix_uri->buf,
- prefix_uri->n_bytes)) {
+ if (!strncmp(uri->buf, prefix_uri->buf, prefix_uri->n_bytes)) {
*prefix = env->prefixes[i].name;
suffix->buf = uri->buf + prefix_uri->n_bytes;
suffix->len = uri->n_bytes - prefix_uri->n_bytes;
@@ -195,8 +192,8 @@ serd_env_expand(const SerdEnv* env,
SerdChunk* uri_prefix,
SerdChunk* uri_suffix)
{
- const uint8_t* const colon =
- (const uint8_t*)memchr(curie->buf, ':', curie->n_bytes + 1);
+ const char* const colon =
+ (const char*)memchr(curie->buf, ':', curie->n_bytes + 1);
if (curie->type != SERD_CURIE || !colon) {
return SERD_ERR_BAD_ARG;
}
@@ -231,9 +228,9 @@ serd_env_expand_node(const SerdEnv* env, const SerdNode* node)
return SERD_NODE_NULL;
}
const size_t len = prefix.len + suffix.len;
- uint8_t* buf = (uint8_t*)malloc(len + 1);
+ char* buf = (char*)malloc(len + 1);
SerdNode ret = {buf, len, 0, SERD_URI};
- snprintf((char*)buf, ret.n_bytes + 1, "%s%s", prefix.buf, suffix.buf);
+ snprintf(buf, ret.n_bytes + 1, "%s%s", prefix.buf, suffix.buf);
return ret;
}
case SERD_BLANK: