From ae26875a61f38ad3be9d87d0ff8953d3f807c09a Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sun, 10 Dec 2017 22:28:35 +0100 Subject: [PATCH] Use the copy_string() helper function in set_filename() copy_string() does the same as the current code, but in one instead of four lines. Strictly speaking, it does not exactly the same thing because the empty string ("") case is handled differently. copy_string() returns NULL instead of a copy of "", which is probably preferred anyway. Signed-off-by: Berthold Stoeger --- core/qthelper.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/core/qthelper.cpp b/core/qthelper.cpp index b63ea3929..341819a96 100644 --- a/core/qthelper.cpp +++ b/core/qthelper.cpp @@ -563,10 +563,7 @@ QLocale getLocale() void set_filename(const char *filename) { free((void *)existing_filename); - if (filename) - existing_filename = strdup(filename); - else - existing_filename = NULL; + existing_filename = copy_string(filename); } const QString get_dc_nickname(const char *model, uint32_t deviceid)