diff options
author | Christopher Faylor <me@cgf.cx> | 2002-05-24 05:44:10 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2002-05-24 05:44:10 +0000 |
commit | ff938546975d416cf33466f54f80ec1b37e2693c (patch) | |
tree | 312bb5600e3a56bc70aa4dd8f4a3b363af5cdb50 /winsup/cygwin/fhandler.cc | |
parent | 7a364eb36494dcac90196db3d93d15086d6c1bc1 (diff) | |
download | cygnal-ff938546975d416cf33466f54f80ec1b37e2693c.tar.gz cygnal-ff938546975d416cf33466f54f80ec1b37e2693c.tar.bz2 cygnal-ff938546975d416cf33466f54f80ec1b37e2693c.zip |
* dtable.cc (dtable::build_fhandler_from_name): Just pass posix path along to
set_name via return_and_clear_normalized_path.
(dtable::build_fhandler): New method with const char * argument.
(dtable::reset_unix_path_name): Eliminate.
(dtable::dup_worker): Use correct build_fhandler method.
* mmap.cc (mmap_record::alloc_fh): Ditto.
* dtable.h (dtable::build_fhandler): New method.
(dtable::reset_unix_path_name): Eliminate.
* fhandler.cc (fhandler_base::set_name): Assume that unix_name has already been
cmalloced.
(fhandler_base::reset_unix_path_name): Eliminate.
(fhandler_base::~fhandler_base): Coercion for cfree.
* fhandler.h (fhandler_base::unix_path_name): Make const char *.
(fhandler_base::win32_path_name): Ditto.
(fhandler_base::reset_unix_path_name): Eliminate.
* fhandler_disk_file.cc (fhandler_cygdrive::set_drives): Accommodate const char
*ness of win32_path_name.
* fhandler_socket.cc (fhandler_socket::fstat): Accommodate new set_name
requirements.
* path.cc (path_conv::return_and_clear_normalized_path): New method.
(path_conv::clear_normalized_path): Eliminate.
(path_conv::~path_conv): Ditto.
(path_conv::check): Accommodate new build_fhandler method.
* path.h (path_conv::~path_conv): Eliminate.
(path_conv::clear_normalized_path): Ditto.
(path_conv::return_and_clear_normalized_path): Declare new method.
Diffstat (limited to 'winsup/cygwin/fhandler.cc')
-rw-r--r-- | winsup/cygwin/fhandler.cc | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc index d1b0a4afc..ff334bfac 100644 --- a/winsup/cygwin/fhandler.cc +++ b/winsup/cygwin/fhandler.cc @@ -161,8 +161,9 @@ fhandler_base::set_name (const char *unix_path, const char *win32_path, int unit else { const char *fmt = get_native_name (); - win32_path_name = (char *) cmalloc (HEAP_STR, strlen(fmt) + 16); - __small_sprintf (win32_path_name, fmt, unit); + char *w = (char *) cmalloc (HEAP_STR, strlen(fmt) + 16); + __small_sprintf (w, fmt, unit); + win32_path_name = w; } if (win32_path_name == NULL) @@ -178,12 +179,15 @@ fhandler_base::set_name (const char *unix_path, const char *win32_path, int unit path_conv. Ideally, we should pass in a format string and build the unix_path, too. */ if (!is_device () || *win32_path_name != '\\') - unix_path_name = cstrdup (unix_path); + unix_path_name = unix_path; else { - unix_path_name = cstrdup (win32_path_name); - for (char *p = unix_path_name; (p = strchr (p, '\\')); p++) - *p = '/'; + char *p = cstrdup (win32_path_name); + unix_path_name = p; + while ((p = strchr (p, '\\')) != NULL) + *p++ = '/'; + if (unix_path) + cfree ((void *) unix_path); } if (unix_path_name == NULL) @@ -194,13 +198,6 @@ fhandler_base::set_name (const char *unix_path, const char *win32_path, int unit namehash = hash_path_name (0, win32_path_name); } -void -fhandler_base::reset_unix_path_name (const char *unix_path) -{ - cfree (unix_path_name); - unix_path_name = cstrdup (unix_path); -} - /* Detect if we are sitting at EOF for conditions where Windows returns an error but UNIX doesn't. */ static int __stdcall @@ -1047,9 +1044,9 @@ fhandler_base::fhandler_base (DWORD devtype, int unit): fhandler_base::~fhandler_base (void) { if (unix_path_name != NULL) - cfree (unix_path_name); + cfree ((void *) unix_path_name); if (win32_path_name != NULL) - cfree (win32_path_name); + cfree ((void *) win32_path_name); if (rabuf) free (rabuf); unix_path_name = win32_path_name = NULL; |