diff options
author | David Robillard <d@drobilla.net> | 2021-01-11 02:45:02 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2021-01-11 13:34:44 +0100 |
commit | 0577775e418250ba696337ab4137f6ae2c244afa (patch) | |
tree | 7773dc68f1769e732caa36e63bad014994e40c50 /src | |
parent | bf75193a3f0ab1fa01e579ea59df75419db26b61 (diff) | |
download | sratom-0577775e418250ba696337ab4137f6ae2c244afa.tar.gz sratom-0577775e418250ba696337ab4137f6ae2c244afa.tar.bz2 sratom-0577775e418250ba696337ab4137f6ae2c244afa.zip |
Avoid use of snprintf for simple string copying
Diffstat (limited to 'src')
-rw-r--r-- | src/sratom.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/sratom.c b/src/sratom.c index b0a0aa4..692257d 100644 --- a/src/sratom.c +++ b/src/sratom.c @@ -676,10 +676,15 @@ read_literal(Sratom* sratom, LV2_Atom_Forge* forge, const SordNode* node) forge, str, len, sratom->map->map(sratom->map->handle, type_uri), 0); } } else if (language) { - const char* prefix = "http://lexvo.org/id/iso639-3/"; - const size_t lang_len = strlen(prefix) + strlen(language); - char* lang_uri = (char*)calloc(lang_len + 1, 1); - snprintf(lang_uri, lang_len + 1, "%s%s", prefix, language); + static const char* const prefix = "http://lexvo.org/id/iso639-3/"; + const size_t prefix_len = strlen(prefix); + const size_t language_len = strlen(language); + const size_t lang_uri_len = prefix_len + language_len; + char* lang_uri = (char*)calloc(lang_uri_len + 1, 1); + + memcpy(lang_uri, prefix, prefix_len + 1); + memcpy(lang_uri + prefix_len, language, language_len + 1); + lv2_atom_forge_literal( forge, str, len, 0, sratom->map->map(sratom->map->handle, lang_uri)); free(lang_uri); |