diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2017-11-18 19:57:50 +0100 |
---|---|---|
committer | Lubomir I. Ivanov <neolit123@gmail.com> | 2017-11-18 21:57:33 +0100 |
commit | 6ae16b87d0560ac06e882da122f43b0e9b913b34 (patch) | |
tree | 7719c68851b20116a9fdc62b3fd71085bdfcdbb7 /core/dive.c | |
parent | f8fcd65bc4598ac150477f6caa64c617ec220982 (diff) | |
download | subsurface-6ae16b87d0560ac06e882da122f43b0e9b913b34.tar.gz |
Constify strings in pref.h
Make all char * pointers in pref.h const to make it clear that these
strings are not mutable. This meant adding a number of (void *) casts
in calls to free(). Apart from being the right thing to do, this commit
makes the code more consistent, as many of the strings in pref.h were
already const.
While touching core/qthelper.cpp turn three instances of (void*) into
(void *).
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/dive.c')
-rw-r--r-- | core/dive.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/core/dive.c b/core/dive.c index c85b869a3..07d47de6f 100644 --- a/core/dive.c +++ b/core/dive.c @@ -3623,11 +3623,12 @@ timestamp_t get_times() void set_userid(char *rUserId) { + char *userid = strdup(rUserId); + if (strlen(userid) > 30) + userid[30] = '\0'; if (prefs.userid) - free(prefs.userid); - prefs.userid = strdup(rUserId); - if (strlen(prefs.userid) > 30) - prefs.userid[30]='\0'; + free((void *)prefs.userid); + prefs.userid = userid; } /* this sets a usually unused copy of the preferences with the units |