aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-08-12 16:40:31 +0200
committerDavid Robillard <d@drobilla.net>2021-03-08 23:23:06 -0500
commit768c05325077776124cabbc01c54f2a511865ebc (patch)
treedb2cfd8461e2dada003a830f31f5c0862531add3
parent0054cff3f5aa1e2c4b5e47fd9b2dfeeff6b17e53 (diff)
downloadserd-768c05325077776124cabbc01c54f2a511865ebc.tar.gz
serd-768c05325077776124cabbc01c54f2a511865ebc.tar.bz2
serd-768c05325077776124cabbc01c54f2a511865ebc.zip
Remove double allocation in serd_env_set_prefix()
-rw-r--r--src/env.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/env.c b/src/env.c
index 145ece33..1afd0ebd 100644
--- a/src/env.c
+++ b/src/env.c
@@ -185,14 +185,15 @@ serd_env_set_prefix(SerdEnv* env,
serd_env_add(env, name, uri);
} else if (!env->base_uri_node) {
return SERD_ERR_BAD_ARG;
- }
+ } else {
+ // Resolve relative URI and create a new node and URI for it
+ SerdNode* const abs_uri = serd_new_resolved_uri(uri, env->base_uri);
- // Resolve relative URI and create a new node and URI for it
- SerdNode* abs_uri = serd_new_resolved_uri(uri, env->base_uri);
+ // Set prefix to resolved (absolute) URI
+ serd_env_add(env, name, serd_node_string_view(abs_uri));
- // Set prefix to resolved (absolute) URI
- serd_env_add(env, name, serd_node_string_view(abs_uri));
- serd_node_free(abs_uri);
+ serd_node_free(abs_uri);
+ }
return SERD_SUCCESS;
}