From c8652c1bdc49445bf4fb0d8f67fab45cff1d2647 Mon Sep 17 00:00:00 2001 From: cancel Date: Wed, 8 Jan 2020 07:52:36 +0900 Subject: [PATCH] Cleanup --- thirdparty/sdd.c | 3 +++ thirdparty/sdd.h | 1 + tui_main.c | 6 ++---- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/thirdparty/sdd.c b/thirdparty/sdd.c index 80b8c4c..ed1fb51 100644 --- a/thirdparty/sdd.c +++ b/thirdparty/sdd.c @@ -112,6 +112,9 @@ sdd *sdd_cpylen(sdd *restrict s, char const *restrict cstr, size_t len) { ((char *)s)[len] = '\0'; return s; } +sdd *sdd_cpysdd(sdd *restrict s, sdd const *restrict other) { + return sdd_cpylen(s, (char const *)other, SDD_HDR(other)->len); +} SDD_NOINLINE sdd *sdd_ensurecap(sdd *s, size_t new_cap) { sdd_header *hdr = SDD_HDR(s); diff --git a/thirdparty/sdd.h b/thirdparty/sdd.h index 3dd9ac6..a173f54 100644 --- a/thirdparty/sdd.h +++ b/thirdparty/sdd.h @@ -57,6 +57,7 @@ sdd *sdd_cpy(sdd *restrict s, char const *restrict cstr) SDD_NONNULL() SDD_USED; // ^- Set `s` to contain the contents of `cstr` sdd *sdd_cpylen(sdd *restrict s, char const *restrict cstr, size_t len) SDD_NONNULL() SDD_USED; +sdd *sdd_cpysdd(sdd *restrict s, sdd const *restrict other); size_t sdd_len(sdd const *s) SDD_NONNULL(); // ^- Bytes used by string (excl. null term) diff --git a/tui_main.c b/tui_main.c index 39b6049..0a6c6ca 100644 --- a/tui_main.c +++ b/tui_main.c @@ -3031,8 +3031,7 @@ int main(int argc, char** argv) { field_load_file(sddc(temp_name), &ged_state.field); if (fle == Field_load_error_ok) { qnav_stack_pop(); - file_name = sdd_cpylen(file_name, sddc(temp_name), - sdd_len(temp_name)); + file_name = sdd_cpysdd(file_name, temp_name); ged_state.filename = sddc(file_name); mbuf_reusable_ensure_size(&ged_state.mbuf_r, ged_state.field.height, @@ -3062,8 +3061,7 @@ int main(int argc, char** argv) { qnav_stack_pop(); bool saved_ok = try_save_with_msg(&ged_state.field, temp_name); if (saved_ok) { - file_name = sdd_cpylen(file_name, sddc(temp_name), - sdd_len(temp_name)); + file_name = sdd_cpysdd(file_name, temp_name); ged_state.filename = sddc(file_name); } }