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 <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2017-12-10 22:28:35 +01:00 committed by Lubomir I. Ivanov
parent ea0cbba804
commit ae26875a61

View file

@ -563,10 +563,7 @@ QLocale getLocale()
void set_filename(const char *filename) void set_filename(const char *filename)
{ {
free((void *)existing_filename); free((void *)existing_filename);
if (filename) existing_filename = copy_string(filename);
existing_filename = strdup(filename);
else
existing_filename = NULL;
} }
const QString get_dc_nickname(const char *model, uint32_t deviceid) const QString get_dc_nickname(const char *model, uint32_t deviceid)