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:
authorChristopher Faylor <me@cgf.cx>2001-10-03 07:49:26 +0400
committerChristopher Faylor <me@cgf.cx>2001-10-03 07:49:26 +0400
commitebd645e7e65aa46fc5e95fda0b47590f4331fc17 (patch)
tree79d88a4c0fe3308a8f58d67aa5b588a37b0aeb7b /winsup/cygwin/environ.cc
parentb519ee2a4e53a65756b9e4f6be4c7bb123d21812 (diff)
* cygheap.cc (cfree): Remove malloc debugging probe.
* dlmalloc.c (errprint): Remove abort() call which causes interesting error message printing to abort prematurely. * environ.cc: Sprinkle MALLOC_CHECKs liberally throughout. (_addenv): Allocate two empty elements at end of environ to (apparently) work around problems with some buggy applications. (winenv): Avoid calling alloca if no forced environment variable is present. * exceptions.cc (open_stackdumpfile): Don't print "Dumping stack trace to..." when running in a cygwin environment (i.e., the parent is a cygwin process). * dtable.cc (dtable::init_std_file_from_handle): Move device type detection code from build_fhandler here since it is only used by this function. (dtable::build_fhandler_from_name): New method. Renamed from dtable::build_fhandler. (dtable::build_fhandler): Use build_fhandler_from_name. (cygwin_attach_handle_to_fd): Ditto. * syscalls.cc (_open): Ditto. (stat_worker): Ditto. * dtable.h (dtable::build_fhandler_from_name): Rename declaration from dtable::build_fhandler.
Diffstat (limited to 'winsup/cygwin/environ.cc')
-rw-r--r--winsup/cygwin/environ.cc38
1 files changed, 22 insertions, 16 deletions
diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc
index c1529e704..e311e4b56 100644
--- a/winsup/cygwin/environ.cc
+++ b/winsup/cygwin/environ.cc
@@ -76,6 +76,7 @@ static unsigned char conv_start_chars[256] = {0};
void
win_env::add_cache (const char *in_posix, const char *in_native)
{
+ MALLOC_CHECK;
posix = (char *) realloc (posix, strlen (in_posix) + 1);
strcpy (posix, in_posix);
if (in_native)
@@ -90,6 +91,7 @@ win_env::add_cache (const char *in_posix, const char *in_native)
(void) strcpy (native, name);
towin32 (in_posix, native + namelen);
}
+ MALLOC_CHECK;
debug_printf ("posix %s", posix);
debug_printf ("native %s", native);
}
@@ -145,6 +147,7 @@ posify (char **here, const char *value)
debug_printf ("env var converted to %s", outenv);
*here = outenv;
free (src);
+ MALLOC_CHECK;
}
/*
@@ -177,6 +180,7 @@ my_findenv (const char *name, int *offset)
*offset = p - cur_environ ();
return (char *) (++c);
}
+ MALLOC_CHECK;
return NULL;
}
@@ -231,12 +235,12 @@ _addenv (const char *name, const char *value, int overwrite)
else
{ /* Create new slot. */
int sz = envsize (cur_environ ());
- int allocsz = sz + sizeof (char *);
+ int allocsz = sz + (2 * sizeof (char *));
offset = (sz - 1) / sizeof (char *);
/* Allocate space for additional element plus terminating NULL. */
- if (__cygwin_environ == lastenviron)
+ if (cur_environ () == lastenviron)
lastenviron = __cygwin_environ = (char **) realloc (cur_environ (),
allocsz);
else if ((lastenviron = (char **) malloc (allocsz)) != NULL)
@@ -248,7 +252,7 @@ _addenv (const char *name, const char *value, int overwrite)
#ifdef DEBUGGING
try_to_debug ();
#endif
- return -1; /* Oops. No more memory. */
+ return -1; /* Oops. No more memory. */
}
__cygwin_environ[offset + 1] = NULL; /* NULL terminate. */
@@ -282,6 +286,7 @@ _addenv (const char *name, const char *value, int overwrite)
if ((spenv = getwinenv (envhere)))
spenv->add_cache (value);
+ MALLOC_CHECK;
return 0;
}
@@ -612,13 +617,11 @@ parse_options (char *buf)
static void __stdcall
regopt (const char *name)
{
- MALLOC_CHECK;
/* FIXME: should not be under mount */
reg_key r (KEY_READ, CYGWIN_INFO_PROGRAM_OPTIONS_NAME, NULL);
char buf[MAX_PATH];
char lname[strlen(name) + 1];
strlwr (strcpy (lname, name));
- MALLOC_CHECK;
if (r.get_string (lname, buf, sizeof (buf) - 1, "") == ERROR_SUCCESS)
parse_options (buf);
else
@@ -810,18 +813,21 @@ winenv (const char * const *envp, int keep_posix)
for (int i = 0; forced_winenv_vars[i]; i++)
if (!saw_forced_winenv[i])
{
- int namelen = strlen (forced_winenv_vars[i]) + 1;
- int vallen = GetEnvironmentVariable (forced_winenv_vars[i], dum, 0) + 1;
- p = (char *) alloca (namelen + vallen);
- strcpy (p, forced_winenv_vars[i]);
- strcat (p, "=");
- if (!GetEnvironmentVariable (forced_winenv_vars[i], p + namelen,
- vallen + 1))
- debug_printf ("warning: %s not present in environment", *srcp);
- else
+ int vallen = GetEnvironmentVariable (forced_winenv_vars[i], dum, 0);
+ if (vallen > 0)
{
- *dstp++ = p;
- tl += strlen (p) + 1;
+ int namelen = strlen (forced_winenv_vars[i]) + 1;
+ p = (char *) alloca (namelen + ++vallen);
+ strcpy (p, forced_winenv_vars[i]);
+ strcat (p, "=");
+ if (!GetEnvironmentVariable (forced_winenv_vars[i], p + namelen,
+ vallen))
+ debug_printf ("warning: %s not present in environment", *srcp);
+ else
+ {
+ *dstp++ = p;
+ tl += strlen (p) + 1;
+ }
}
}