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>
This commit is contained in:
Berthold Stoeger 2018-08-14 16:12:42 -04:00 committed by Dirk Hohndel
parent f2c45c8187
commit a781d3a44e

View file

@ -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);
}
}