diff options
author | Christopher Faylor <me@cgf.cx> | 2011-10-20 21:35:59 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2011-10-20 21:35:59 +0000 |
commit | b2099ee728addd34b0497bcddcc0fcd6a2503f0b (patch) | |
tree | 0157d0ebb9960fafdb4bb2c416bffea388ce6a5f /winsup/cygwin/path.h | |
parent | 38d732a152ff27601b385c00e6574111461b65c4 (diff) | |
download | cygnal-b2099ee728addd34b0497bcddcc0fcd6a2503f0b.tar.gz cygnal-b2099ee728addd34b0497bcddcc0fcd6a2503f0b.tar.bz2 cygnal-b2099ee728addd34b0497bcddcc0fcd6a2503f0b.zip |
* fhandler.h (fhandler*::copyto): Free path_conv strings first.
* path.h (cfree_and_null): Rename and expand from cfree_maybe.
(path_conv &operator =): Call free_strings rather than freeing strings
directly.
Diffstat (limited to 'winsup/cygwin/path.h')
-rw-r--r-- | winsup/cygwin/path.h | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/winsup/cygwin/path.h b/winsup/cygwin/path.h index 3a9c08ca4..f390156cc 100644 --- a/winsup/cygwin/path.h +++ b/winsup/cygwin/path.h @@ -282,12 +282,21 @@ class path_conv PWCHAR get_wide_win32_path (PWCHAR wc); operator DWORD &() {return fileattr;} operator int () {return fileattr; } -# define cfree_maybe(x) if (x) cfree ((void *) (x)) +# define cfree_and_null(x) \ + if (x) \ + { \ + cfree ((void *) (x)); \ + (x) = NULL; \ + } + void free_strings () + { + cfree_and_null (path); + cfree_and_null (normalized_path); + cfree_and_null (wide_path); + } path_conv &operator =(const path_conv& pc) { - cfree_maybe (path); - cfree_maybe (normalized_path); - cfree_maybe (wide_path); + free_strings (); memcpy (this, &pc, sizeof pc); path = cstrdup (pc.path); conv_handle.dup (pc.conv_handle); |