summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/fhandler.cc
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2003-07-09 01:33:06 +0000
committerChristopher Faylor <me@cgf.cx>2003-07-09 01:33:06 +0000
commit4d782b426a09120642906e12e21bf669b7bb77db (patch)
tree514a0f6f1034d3bf897b6f7d7c365779fa40c44b /winsup/cygwin/fhandler.cc
parenta42408549f7b286dda7f333b5b977caf67fc1cdd (diff)
downloadcygnal-4d782b426a09120642906e12e21bf669b7bb77db.tar.gz
cygnal-4d782b426a09120642906e12e21bf669b7bb77db.tar.bz2
cygnal-4d782b426a09120642906e12e21bf669b7bb77db.zip
* cygheap.cc (creturn): Set appropriate errno when out of memory.
(ccalloc): Only issue system_printf when debugging. * dtable.cc (dtable::extend): Only allocate 100 * the incremental growth size max. Set errno appropriately. (dtable::build_fhandler): Check for error from set_name. * fhandler.cc (fhandler_base::set_name): Set errno and return error on OOM. * fhandler.h (fhandler_base::set_name): Change to bool. * fhandler_process.cc (format_process_stat): Fix formatting. * resource.cc (getrlimit): Return greater of OPEN_MAX or fd table size. * sysconf.cc (sysconf): Ditto.
Diffstat (limited to 'winsup/cygwin/fhandler.cc')
-rw-r--r--winsup/cygwin/fhandler.cc20
1 files changed, 13 insertions, 7 deletions
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index 69fd48a7b..2ab56f5da 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -149,11 +149,11 @@ fhandler_base::get_readahead_into_buffer (char *buf, size_t buflen)
in cases where the name is really required, the filename wouldn't ever
be too long (e.g. devices or some such).
The unix_path_name is also used by virtual fhandlers. */
-void
+bool
fhandler_base::set_name (const char *unix_path, const char *win32_path, int unit)
{
if (unix_path == NULL || !*unix_path)
- return;
+ return false;
if (win32_path)
win32_path_name = cstrdup (win32_path);
@@ -161,14 +161,16 @@ fhandler_base::set_name (const char *unix_path, const char *win32_path, int unit
{
const char *fmt = get_native_name ();
char *w = (char *) cmalloc (HEAP_STR, strlen (fmt) + 16);
- __small_sprintf (w, fmt, unit);
+ if (w)
+ __small_sprintf (w, fmt, unit);
win32_path_name = w;
}
if (win32_path_name == NULL)
{
system_printf ("fatal error. strdup failed");
- exit (ENOMEM);
+ set_errno (ENOMEM);
+ return false;
}
assert (unix_path_name == NULL);
@@ -183,8 +185,9 @@ fhandler_base::set_name (const char *unix_path, const char *win32_path, int unit
{
char *p = cstrdup (win32_path_name);
unix_path_name = p;
- while ((p = strchr (p, '\\')) != NULL)
- *p++ = '/';
+ if (p)
+ while ((p = strchr (p, '\\')) != NULL)
+ *p++ = '/';
if (unix_path)
cfree ((void *) unix_path);
}
@@ -192,9 +195,12 @@ fhandler_base::set_name (const char *unix_path, const char *win32_path, int unit
if (unix_path_name == NULL)
{
system_printf ("fatal error. strdup failed");
- exit (ENOMEM);
+ free ((void *) win32_path_name);
+ set_errno (ENOMEM);
+ return false;
}
namehash = hash_path_name (0, win32_path_name);
+ return true;
}
/* Detect if we are sitting at EOF for conditions where Windows