diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2018-08-14 16:12:42 -0400 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-08-14 14:13:52 -0700 |
commit | a781d3a44ea136af4e166e9018644166a9755f54 (patch) | |
tree | fcd327b94a0a93f3585cff51974ab3220b0dc5f5 /core/unix.c | |
parent | f2c45c81878bd62e5a37e3cb7f26961e6286d1cd (diff) | |
download | subsurface-a781d3a44ea136af4e166e9018644166a9755f54.tar.gz |
Cleanup: fix warning in unix.c
The compiler complained about assigning the "const char *" returned by
mb_cstring() to a "char *". The warning is correct, as the returned
buffer still belongs to the membuffer. The code only worked because
destruction of the membuffer was "forgotten".
Fix this by using the "detach_buffer()" function, which passes ownership
to the caller and accordingly returns a "char *".
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/unix.c')
-rw-r--r-- | core/unix.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/core/unix.c b/core/unix.c index 963d25ac5..a75bcd792 100644 --- a/core/unix.c +++ b/core/unix.c @@ -48,7 +48,8 @@ void subsurface_user_info(struct user_info *user) struct membuffer mb = {}; gethostname(hostname, sizeof(hostname)); put_format(&mb, "%s@%s", username, hostname); - user->email = mb_cstring(&mb); // 'email' is heap allocated + mb_cstring(&mb); + user->email = detach_buffer(&mb); } } |