* 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.
This commit is contained in:
Christopher Faylor
2011-10-20 21:35:59 +00:00
parent 38d732a152
commit b2099ee728
2 changed files with 45 additions and 4 deletions

View File

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