Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2009-07-30 12:56:57 +0400
committerCorinna Vinschen <corinna@vinschen.de>2009-07-30 12:56:57 +0400
commit0986989f6a290a15e9229f65dd4846d97ee1864e (patch)
tree041af38e8601244205124efd21317c6f26b4aade /winsup/cygwin/path.h
parent7d3c3d30e7633d9c947c0550b0d4051a7d5947d1 (diff)
* path.h (class path_conv): Convert path from char array to char *.
Initialize to NULL in constructors. Drop normalized_path_size member. (path_conv::size): Remove. (path_conv::operator =): Always copy with sizeof path_conv. Always duplicate path on cygheap. (path_conv::set_path): Move implementation to spawn.cc. * path.cc (path_conv::set_normalized_path): Always allocate normalized_path on cygheap. (path_conv::check): Don't work on path, rather allocate THIS_path in TLS and use it throughout. When finished, allocate path on cygheap and copy over. Defer tacking on extension after having copied path. * spawn.cc (path_conv::set_path): Implement here.
Diffstat (limited to 'winsup/cygwin/path.h')
-rw-r--r--winsup/cygwin/path.h32
1 files changed, 13 insertions, 19 deletions
diff --git a/winsup/cygwin/path.h b/winsup/cygwin/path.h
index 952e0584a..7a8033d3d 100644
--- a/winsup/cygwin/path.h
+++ b/winsup/cygwin/path.h
@@ -83,6 +83,8 @@ enum path_types
PATH_SOCKET = 0x40000000
};
+extern "C" char *__stdcall cstrdup (const char *s);
+
class symlink_info;
class path_conv
@@ -163,40 +165,36 @@ class path_conv
path_conv (const device& in_dev)
: fileattr (INVALID_FILE_ATTRIBUTES), wide_path (NULL), path_flags (0),
- known_suffix (NULL), error (0), dev (in_dev), normalized_path (NULL),
- normalized_path_size (0)
+ known_suffix (NULL), error (0), dev (in_dev), normalized_path (NULL)
{
- strcpy (path, in_dev.native);
+ path = cstrdup (in_dev.native);
}
path_conv (int, const char *src, unsigned opt = PC_SYM_FOLLOW,
const suffix_info *suffixes = NULL)
- : wide_path (NULL), normalized_path (NULL), normalized_path_size (0)
+ : wide_path (NULL), normalized_path (NULL), path (NULL)
{
check (src, opt, suffixes);
}
path_conv (const UNICODE_STRING *src, unsigned opt = PC_SYM_FOLLOW,
const suffix_info *suffixes = NULL)
- : wide_path (NULL), normalized_path (NULL), normalized_path_size (0)
+ : wide_path (NULL), normalized_path (NULL), path (NULL)
{
check (src, opt | PC_NULLEMPTY, suffixes);
}
path_conv (const char *src, unsigned opt = PC_SYM_FOLLOW,
const suffix_info *suffixes = NULL)
- : wide_path (NULL), normalized_path (NULL), normalized_path_size (0)
+ : wide_path (NULL), normalized_path (NULL), path (NULL)
{
check (src, opt | PC_NULLEMPTY, suffixes);
}
path_conv ()
: fileattr (INVALID_FILE_ATTRIBUTES), wide_path (NULL), path_flags (0),
- known_suffix (NULL), error (0), normalized_path (NULL),
- normalized_path_size (0)
- {
- path[0] = '\0';
- }
+ known_suffix (NULL), error (0), normalized_path (NULL), path (NULL)
+ {}
~path_conv ();
inline char *get_win32 () { return path; }
@@ -214,7 +212,8 @@ class path_conv
operator int () {return fileattr; }
path_conv &operator =(path_conv &pc)
{
- memcpy (this, &pc, pc.size ());
+ memcpy (this, &pc, sizeof pc);
+ path = cstrdup (pc.path);
set_normalized_path (pc.normalized_path);
wide_path = NULL;
return *this;
@@ -233,22 +232,17 @@ class path_conv
bool fs_is_cdrom () const {return fs.is_cdrom ();}
bool fs_is_mvfs () const {return fs.is_mvfs ();}
ULONG fs_serial_number () const {return fs.serial_number ();}
- void set_path (const char *p) {strcpy (path, p);}
+ inline void set_path (const char *p);
void fillin (HANDLE h);
- inline size_t size ()
- {
- return (sizeof (*this) - sizeof (path)) + strlen (path) + 1 + normalized_path_size;
- }
bool is_binary ();
unsigned __stdcall ndisk_links (DWORD);
char *normalized_path;
- size_t normalized_path_size;
void set_normalized_path (const char *) __attribute__ ((regparm (2)));
DWORD get_symlink_length () { return symlink_length; };
private:
DWORD symlink_length;
- char path[NT_MAX_PATH];
+ char *path;
};
/* Symlink marker */