diff options
author | sanine <sanine.not@pm.me> | 2023-02-04 00:27:55 -0600 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2023-02-04 00:27:55 -0600 |
commit | 0bb180e4ddeebf6d219a38b862ce3e8238f99c54 (patch) | |
tree | 9556fd77d16cdcee69ff0c9c0765c408ee88ae19 /src/geometry | |
parent | 6292c2bce712dcca01ded960dc5f93528da2b9ce (diff) |
add kai_tag_attr_to_dup()
Diffstat (limited to 'src/geometry')
-rw-r--r-- | src/geometry/geometry.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/geometry/geometry.c b/src/geometry/geometry.c index fd42735..ad23853 100644 --- a/src/geometry/geometry.c +++ b/src/geometry/geometry.c @@ -13,21 +13,16 @@ int kai_read_float_array(struct ka_float_array_t *dest, struct kai_tag_t *src) return -1; } - int flag; - dest->count = kai_tag_attr_to_long(src, "count", 0, &flag); - if (flag != 0) { + long count = kai_tag_attr_to_long(src, "count", -1); + if (count == -1) { /* count not present */ return -1; } - char *id = kai_tag_get_attr(src, "id"); - if (id != NULL) - dest->id = strdup(id); - else - dest->id = NULL; - - dest->digits = kai_tag_attr_to_long(src, "digits", 6, NULL); - dest->magnitude = kai_tag_attr_to_long(src, "magnitude", 38, NULL); + dest->count = count; + dest->id = kai_tag_attr_to_dup(src, "id"); + dest->digits = kai_tag_attr_to_long(src, "digits", 6); + dest->magnitude = kai_tag_attr_to_long(src, "magnitude", 38); /* allocate & fill buffer */ dest->buf = malloc(dest->count * sizeof(ka_real_t)); |