shithub: orca

Download patch

ref: c8652c1bdc49445bf4fb0d8f67fab45cff1d2647
parent: 5fb0071da18c0bacf0059533c73e3938882a4531
author: cancel <cancel@cancel.fm>
date: Wed Jan 8 02:52:36 EST 2020

Cleanup

--- a/thirdparty/sdd.c
+++ b/thirdparty/sdd.c
@@ -112,6 +112,9 @@
   ((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);
--- a/thirdparty/sdd.h
+++ b/thirdparty/sdd.h
@@ -57,6 +57,7 @@
 // ^- 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)
--- a/tui_main.c
+++ b/tui_main.c
@@ -3031,8 +3031,7 @@
                     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 @@
                 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);
                 }
               }