summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/pinfo.cc
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2005-08-24 04:38:39 +0000
committerChristopher Faylor <me@cgf.cx>2005-08-24 04:38:39 +0000
commit14c4d65ef1240b1c18db06c3030b4e0830b0c701 (patch)
tree0a651de83d4520bb1c08dd334792733560733975 /winsup/cygwin/pinfo.cc
parentdb7f135b03afa5f8ee870f87d1727d69dade30ce (diff)
downloadcygnal-14c4d65ef1240b1c18db06c3030b4e0830b0c701.tar.gz
cygnal-14c4d65ef1240b1c18db06c3030b4e0830b0c701.tar.bz2
cygnal-14c4d65ef1240b1c18db06c3030b4e0830b0c701.zip
* cygheap.h (cygheap_types): Add HEAP_COMMUNE.
* fhandler_proc.cc: Use cygheap rather than user heap for allocation of filebuf throughout. * fhandler_registry.cc: Ditto. * fhandler_virtual.cc: Ditto. * fhandler_process.cc: Ditto. (get_mem_values): Use malloc/realloc/free rather than new. * pinfo.cc (_pinfo::commune_send): Allocate on cygwin heap rather than user heap. Avoid calling ReadFile when correct number of characters have been read or suffer buffer corruption. (_pinfo::fd): Allocate on cygwin heap rather than user heap. (_pinfo::fds): Ditto. (_pinfo::root): Ditto. (_pinfo::cwd): Ditto. (_pinfo::cmdline): Ditto. * devices.h (FH_DEV): New define. * devices.in: Detect lone /dev. * devices.cc: Regenerate. * path.cc (path_conv::check): Treat FH_DEV as a special case.
Diffstat (limited to 'winsup/cygwin/pinfo.cc')
-rw-r--r--winsup/cygwin/pinfo.cc18
1 files changed, 9 insertions, 9 deletions
diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc
index e253cac5d..babed0cde 100644
--- a/winsup/cygwin/pinfo.cc
+++ b/winsup/cygwin/pinfo.cc
@@ -727,9 +727,9 @@ _pinfo::commune_send (DWORD code, ...)
res.s = NULL;
else
{
- res.s = (char *) malloc (n);
+ res.s = (char *) cmalloc (HEAP_COMMUNE, n);
char *p;
- for (p = res.s; ReadFile (fromthem, p, n, &nr, NULL); p += nr)
+ for (p = res.s; n && ReadFile (fromthem, p, n, &nr, NULL); p += nr, n -= nr)
continue;
if ((unsigned) (p - res.s) != n)
{
@@ -817,9 +817,9 @@ _pinfo::fd (int fd, size_t &n)
{
cygheap_fdget cfd (fd);
if (cfd < 0)
- s = strdup ("");
+ s = cstrdup ("");
else
- s = cfd->get_proc_fd_name ((char *) malloc (CYG_MAX_PATH));
+ s = cfd->get_proc_fd_name ((char *) cmalloc (HEAP_COMMUNE, CYG_MAX_PATH));
n = strlen (s) + 1;
}
return s;
@@ -845,7 +845,7 @@ _pinfo::fds (size_t &n)
while ((fd = cfd.next ()) >= 0)
n += sizeof (int);
cfd.rewind ();
- s = (char *) malloc (n);
+ s = (char *) cmalloc (HEAP_COMMUNE, n);
int *p = (int *) s;
while ((fd = cfd.next ()) >= 0 && (char *) p - s < (int) n)
*p++ = fd;
@@ -868,9 +868,9 @@ _pinfo::root (size_t& n)
else
{
if (cygheap->root.exists ())
- s = strdup (cygheap->root.posix_path ());
+ s = cstrdup (cygheap->root.posix_path ());
else
- s = strdup ("/");
+ s = cstrdup ("/");
n = strlen (s) + 1;
}
return s;
@@ -890,7 +890,7 @@ _pinfo::cwd (size_t& n)
}
else
{
- s = (char *) malloc (CYG_MAX_PATH);
+ s = (char *) cmalloc (HEAP_COMMUNE, CYG_MAX_PATH);
cygheap->cwd.get (s, 1, 1, CYG_MAX_PATH);
n = strlen (s) + 1;
}
@@ -915,7 +915,7 @@ _pinfo::cmdline (size_t& n)
for (char **a = __argv; *a; a++)
n += strlen (*a) + 1;
char *p;
- p = s = (char *) malloc (n);
+ p = s = (char *) cmalloc (HEAP_COMMUNE, n);
for (char **a = __argv; *a; a++)
{
strcpy (p, *a);