diff options
author | lloyd <[email protected]> | 2010-06-13 16:04:21 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-06-13 16:04:21 +0000 |
commit | 271a9cea240fe437771ea776cd5fb4a087d833fe (patch) | |
tree | ad1ce08f543098d0ab0e94f56c4c6b95bfeb057c /src/s2k/s2k.h | |
parent | df0222e101d908151be837e7ef46ab715f71973f (diff) |
Change how alloc_mmap's TemporaryFile class works. Don't expose
the name at all; instead unlink it at the end of the constructor,
so by the time it is fully constructed it is purely an anonymous
file descriptor.
mkstemp has a weird interface and returns the final name of the
file in its template argument. This prevented us from using a
std::string, since c_str's return is const (and we can't use
&string[0], because that might not be NULL-terminated). This
previously required doing nasty things like explicit new/delete
and using strcpy (the strcpy was what got me started on looking
at this; OpenBSD complains about it, so I was trying to figure
out a good way to remove it).
Instead, use the idea from http://www.gotw.ca/gotw/042.htm, and
use a std::vector to hold the mkstemp argument/result. That works
consistently everywhere, and we don't need to rely on strcpy, and
don't have to worry about memory leaks either. Only minor nit is
having to add an explicit NULL terminator as the std::string
doesn't contain it.
Diffstat (limited to 'src/s2k/s2k.h')
0 files changed, 0 insertions, 0 deletions