summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/path.h
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/cygwin/path.h')
-rw-r--r--winsup/cygwin/path.h17
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);