Change many cygheap allocation routines to their *_abort analogs.
* cygheap.cc (cmalloc_abort): New function. (crealloc_abort): Ditto. (ccalloc_abort): Ditto.
This commit is contained in:
parent
32cba6cb3a
commit
ee4388c420
|
@ -1,3 +1,10 @@
|
|||
2007-11-26 Christopher Faylor <me+cygwin@cgf.cx>
|
||||
|
||||
Change many cygheap allocation routines to their *_abort analogs.
|
||||
* cygheap.cc (cmalloc_abort): New function.
|
||||
(crealloc_abort): Ditto.
|
||||
(ccalloc_abort): Ditto.
|
||||
|
||||
2007-11-23 Christopher Faylor <me+cygwin@cgf.cx>
|
||||
|
||||
* cygheap.cc (_crealloc): Avoid memcpy when _cmalloc returns NULL.
|
||||
|
|
|
@ -249,13 +249,16 @@ _crealloc (void *ptr, unsigned size)
|
|||
#define tocygheap(s) ((cygheap_entry *) (((char *) (s)) - (int) (N->data)))
|
||||
|
||||
inline static void *
|
||||
creturn (cygheap_types x, cygheap_entry * c, unsigned len)
|
||||
creturn (cygheap_types x, cygheap_entry * c, unsigned len, const char *fn = NULL)
|
||||
{
|
||||
if (!c)
|
||||
{
|
||||
set_errno (ENOMEM);
|
||||
return NULL;
|
||||
}
|
||||
if (fn)
|
||||
api_fatal ("%s would have returned NULL", fn);
|
||||
else
|
||||
{
|
||||
set_errno (ENOMEM);
|
||||
return NULL;
|
||||
}
|
||||
c->type = x;
|
||||
char *cend = ((char *) c + sizeof (*c) + len);
|
||||
if (cygheap_max < cend)
|
||||
|
@ -264,24 +267,29 @@ creturn (cygheap_types x, cygheap_entry * c, unsigned len)
|
|||
return (void *) c->data;
|
||||
}
|
||||
|
||||
extern "C" void *__stdcall
|
||||
cmalloc (cygheap_types x, DWORD n)
|
||||
inline static void *
|
||||
cmalloc (cygheap_types x, DWORD n, const char *fn)
|
||||
{
|
||||
cygheap_entry *c;
|
||||
MALLOC_CHECK;
|
||||
c = (cygheap_entry *) _cmalloc (sizeof_cygheap (n));
|
||||
if (!c)
|
||||
{
|
||||
#ifdef DEBUGGING
|
||||
system_printf ("cmalloc returned NULL");
|
||||
try_to_debug ();
|
||||
#endif
|
||||
}
|
||||
return creturn (x, c, n);
|
||||
return creturn (x, c, n, fn);
|
||||
}
|
||||
|
||||
extern "C" void *__stdcall
|
||||
crealloc (void *s, DWORD n)
|
||||
extern "C" void *
|
||||
cmalloc (cygheap_types x, DWORD n)
|
||||
{
|
||||
return cmalloc (x, n, NULL);
|
||||
}
|
||||
|
||||
extern "C" void *
|
||||
cmalloc_abort (cygheap_types x, DWORD n)
|
||||
{
|
||||
return cmalloc (x, n, "cmalloc");
|
||||
}
|
||||
|
||||
inline static void *
|
||||
crealloc (void *s, DWORD n, const char *fn)
|
||||
{
|
||||
MALLOC_CHECK;
|
||||
if (s == NULL)
|
||||
|
@ -291,11 +299,19 @@ crealloc (void *s, DWORD n)
|
|||
cygheap_entry *c = tocygheap (s);
|
||||
cygheap_types t = (cygheap_types) c->type;
|
||||
c = (cygheap_entry *) _crealloc (c, sizeof_cygheap (n));
|
||||
#ifdef DEBUGGING
|
||||
if (!c)
|
||||
system_printf ("crealloc returned NULL");
|
||||
#endif
|
||||
return creturn (t, c, n);
|
||||
return creturn (t, c, n, fn);
|
||||
}
|
||||
|
||||
extern "C" void *__stdcall
|
||||
crealloc (void *s, DWORD n)
|
||||
{
|
||||
return crealloc (s, n, NULL);
|
||||
}
|
||||
|
||||
extern "C" void *__stdcall
|
||||
crealloc_abort (void *s, DWORD n)
|
||||
{
|
||||
return crealloc (s, n, "crealloc");
|
||||
}
|
||||
|
||||
extern "C" void __stdcall
|
||||
|
@ -314,8 +330,8 @@ cfree_and_set (char *&s, char *what)
|
|||
s = what;
|
||||
}
|
||||
|
||||
extern "C" void *__stdcall
|
||||
ccalloc (cygheap_types x, DWORD n, DWORD size)
|
||||
inline static void *
|
||||
ccalloc (cygheap_types x, DWORD n, DWORD size, const char *fn)
|
||||
{
|
||||
cygheap_entry *c;
|
||||
MALLOC_CHECK;
|
||||
|
@ -323,11 +339,19 @@ ccalloc (cygheap_types x, DWORD n, DWORD size)
|
|||
c = (cygheap_entry *) _cmalloc (sizeof_cygheap (n));
|
||||
if (c)
|
||||
memset (c->data, 0, n);
|
||||
#ifdef DEBUGGING
|
||||
if (!c)
|
||||
system_printf ("ccalloc returned NULL");
|
||||
#endif
|
||||
return creturn (x, c, n);
|
||||
return creturn (x, c, n, fn);
|
||||
}
|
||||
|
||||
extern "C" void *__stdcall
|
||||
ccalloc (cygheap_types x, DWORD n, DWORD size)
|
||||
{
|
||||
return ccalloc (x, n, size, NULL);
|
||||
}
|
||||
|
||||
extern "C" void *__stdcall
|
||||
ccalloc_abort (cygheap_types x, DWORD n, DWORD size)
|
||||
{
|
||||
return ccalloc (x, n, size, "ccalloc");
|
||||
}
|
||||
|
||||
extern "C" char *__stdcall
|
||||
|
|
|
@ -418,6 +418,9 @@ void __stdcall cfree (void *) __attribute__ ((regparm(1)));
|
|||
void *__stdcall cmalloc (cygheap_types, DWORD) __attribute__ ((regparm(2)));
|
||||
void *__stdcall crealloc (void *, DWORD) __attribute__ ((regparm(2)));
|
||||
void *__stdcall ccalloc (cygheap_types, DWORD, DWORD) __attribute__ ((regparm(3)));
|
||||
void *__stdcall cmalloc_abort (cygheap_types, DWORD) __attribute__ ((regparm(2)));
|
||||
void *__stdcall crealloc_abort (void *, DWORD) __attribute__ ((regparm(2)));
|
||||
void *__stdcall ccalloc_abort (cygheap_types, DWORD, DWORD) __attribute__ ((regparm(3)));
|
||||
char *__stdcall cstrdup (const char *) __attribute__ ((regparm(1)));
|
||||
char *__stdcall cstrdup1 (const char *) __attribute__ ((regparm(1)));
|
||||
void __stdcall cfree_and_set (char *&, char * = NULL) __attribute__ ((regparm(2)));
|
||||
|
|
|
@ -53,8 +53,8 @@ _cygtls::init ()
|
|||
else
|
||||
{
|
||||
cygheap->sthreads = THREADLIST_CHUNK;
|
||||
cygheap->threadlist = (_cygtls **) ccalloc (HEAP_TLS, cygheap->sthreads,
|
||||
sizeof (cygheap->threadlist[0]));
|
||||
cygheap->threadlist = (_cygtls **) ccalloc_abort (HEAP_TLS, cygheap->sthreads,
|
||||
sizeof (cygheap->threadlist[0]));
|
||||
}
|
||||
sentry::lock.init ("sentry_lock");
|
||||
}
|
||||
|
@ -119,8 +119,8 @@ _cygtls::init_thread (void *x, DWORD (*func) (void *, void *))
|
|||
if (nthreads >= cygheap->sthreads)
|
||||
{
|
||||
cygheap->threadlist = (_cygtls **)
|
||||
crealloc (cygheap->threadlist, (cygheap->sthreads += THREADLIST_CHUNK)
|
||||
* sizeof (cygheap->threadlist[0]));
|
||||
crealloc_abort (cygheap->threadlist, (cygheap->sthreads += THREADLIST_CHUNK)
|
||||
* sizeof (cygheap->threadlist[0]));
|
||||
memset (cygheap->threadlist + nthreads, 0, THREADLIST_CHUNK * sizeof (cygheap->threadlist[0]));
|
||||
}
|
||||
|
||||
|
|
|
@ -844,7 +844,7 @@ handle_to_fn (HANDLE h, char *posix_fn)
|
|||
NTSTATUS res = NtQueryObject (h, ObjectNameInformation, ntfn, sizeof (fnbuf),
|
||||
NULL);
|
||||
|
||||
if (NT_SUCCESS (res))
|
||||
if (!NT_SUCCESS (res))
|
||||
{
|
||||
strcpy (posix_fn, unknown_file);
|
||||
debug_printf ("NtQueryObject failed");
|
||||
|
|
|
@ -248,7 +248,7 @@ getearly (const char * name, int *)
|
|||
return *ptr + len + 1;
|
||||
}
|
||||
else if ((len = GetEnvironmentVariable (name, NULL, 0))
|
||||
&& (ret = (char *) cmalloc (HEAP_2_STR, len))
|
||||
&& (ret = (char *) cmalloc_abort (HEAP_2_STR, len))
|
||||
&& GetEnvironmentVariable (name, ret, len))
|
||||
return ret;
|
||||
|
||||
|
@ -848,7 +848,7 @@ getwinenveq (const char *name, size_t namelen, int x)
|
|||
totlen += namelen;
|
||||
else
|
||||
namelen = 0;
|
||||
char *p = (char *) cmalloc ((cygheap_types) x, totlen);
|
||||
char *p = (char *) cmalloc_abort ((cygheap_types) x, totlen);
|
||||
if (namelen)
|
||||
strcpy (p, name);
|
||||
if (GetEnvironmentVariable (name0, p + namelen, totlen))
|
||||
|
@ -919,7 +919,7 @@ spenv::retrieve (bool no_envblock, const char *const env)
|
|||
p = (cygheap->user.*from_cygheap) (name, namelen);
|
||||
if (!p || (no_envblock && !env) || (p == env_dontadd))
|
||||
return env_dontadd;
|
||||
char *s = (char *) cmalloc (HEAP_1_STR, namelen + strlen (p) + 1);
|
||||
char *s = (char *) cmalloc_abort (HEAP_1_STR, namelen + strlen (p) + 1);
|
||||
strcpy (s, name);
|
||||
strcpy (s + namelen, p);
|
||||
debug_printf ("using computed value for '%s'", name);
|
||||
|
@ -954,7 +954,7 @@ build_env (const char * const *envp, char *&envblock, int &envc,
|
|||
continue;
|
||||
|
||||
/* Allocate a new "argv-style" environ list with room for extra stuff. */
|
||||
char **newenv = (char **) cmalloc (HEAP_1_ARGV, sizeof (char *) *
|
||||
char **newenv = (char **) cmalloc_abort (HEAP_1_ARGV, sizeof (char *) *
|
||||
(n + SPENVS_SIZE + 1));
|
||||
|
||||
int tl = 0;
|
||||
|
|
|
@ -1241,7 +1241,7 @@ fhandler_console::char_command (char c)
|
|||
|
||||
if (dev_state->savebuf)
|
||||
cfree (dev_state->savebuf);
|
||||
dev_state->savebuf = (PCHAR_INFO) cmalloc (HEAP_1_BUF, sizeof (CHAR_INFO) *
|
||||
dev_state->savebuf = (PCHAR_INFO) cmalloc_abort (HEAP_1_BUF, sizeof (CHAR_INFO) *
|
||||
dev_state->savebufsiz.X * dev_state->savebufsiz.Y);
|
||||
|
||||
ReadConsoleOutputA (get_output_handle (), dev_state->savebuf,
|
||||
|
|
|
@ -983,7 +983,7 @@ fhandler_dev_dsp::open (int flags, mode_t mode)
|
|||
nohandle (true);
|
||||
|
||||
// FIXME: Do this better someday
|
||||
fhandler_dev_dsp *arch = (fhandler_dev_dsp *) cmalloc (HEAP_ARCHETYPES, sizeof (*this));
|
||||
fhandler_dev_dsp *arch = (fhandler_dev_dsp *) cmalloc_abort (HEAP_ARCHETYPES, sizeof (*this));
|
||||
archetype = arch;
|
||||
*((fhandler_dev_dsp **) cygheap->fdtab.add_archetype ()) = arch;
|
||||
*arch = *this;
|
||||
|
|
|
@ -357,7 +357,7 @@ fhandler_proc::fill_filebuf ()
|
|||
bufalloc = strlen (uts_name.sysname) + 1
|
||||
+ strlen (uts_name.release) + 1
|
||||
+ strlen (uts_name.version) + 2;
|
||||
filebuf = (char *) crealloc (filebuf, bufalloc);
|
||||
filebuf = (char *) crealloc_abort (filebuf, bufalloc);
|
||||
filesize = __small_sprintf (filebuf, "%s %s %s\n",
|
||||
uts_name.sysname, uts_name.release,
|
||||
uts_name.version);
|
||||
|
@ -366,13 +366,13 @@ fhandler_proc::fill_filebuf ()
|
|||
}
|
||||
case PROC_UPTIME:
|
||||
{
|
||||
filebuf = (char *) crealloc (filebuf, bufalloc = 80);
|
||||
filebuf = (char *) crealloc_abort (filebuf, bufalloc = 80);
|
||||
filesize = format_proc_uptime (filebuf, bufalloc);
|
||||
break;
|
||||
}
|
||||
case PROC_STAT:
|
||||
{
|
||||
filebuf = (char *) crealloc (filebuf, bufalloc = 16384);
|
||||
filebuf = (char *) crealloc_abort (filebuf, bufalloc = 16384);
|
||||
filesize = format_proc_stat (filebuf, bufalloc);
|
||||
break;
|
||||
}
|
||||
|
@ -383,32 +383,32 @@ fhandler_proc::fill_filebuf ()
|
|||
* Windows 95/98/me does have the KERNEL/CPUUsage performance counter
|
||||
* which is similar.
|
||||
*/
|
||||
filebuf = (char *) crealloc (filebuf, bufalloc = 16);
|
||||
filebuf = (char *) crealloc_abort (filebuf, bufalloc = 16);
|
||||
filesize = __small_sprintf (filebuf, "%u.%02u %u.%02u %u.%02u\n",
|
||||
0, 0, 0, 0, 0, 0);
|
||||
break;
|
||||
}
|
||||
case PROC_MEMINFO:
|
||||
{
|
||||
filebuf = (char *) crealloc (filebuf, bufalloc = 2048);
|
||||
filebuf = (char *) crealloc_abort (filebuf, bufalloc = 2048);
|
||||
filesize = format_proc_meminfo (filebuf, bufalloc);
|
||||
break;
|
||||
}
|
||||
case PROC_CPUINFO:
|
||||
{
|
||||
filebuf = (char *) crealloc (filebuf, bufalloc = 16384);
|
||||
filebuf = (char *) crealloc_abort (filebuf, bufalloc = 16384);
|
||||
filesize = format_proc_cpuinfo (filebuf, bufalloc);
|
||||
break;
|
||||
}
|
||||
case PROC_PARTITIONS:
|
||||
{
|
||||
filebuf = (char *) crealloc (filebuf, bufalloc = 4096);
|
||||
filebuf = (char *) crealloc_abort (filebuf, bufalloc = 4096);
|
||||
filesize = format_proc_partitions (filebuf, bufalloc);
|
||||
break;
|
||||
}
|
||||
case PROC_SELF:
|
||||
{
|
||||
filebuf = (char *) crealloc (filebuf, bufalloc = 32);
|
||||
filebuf = (char *) crealloc_abort (filebuf, bufalloc = 32);
|
||||
filesize = __small_sprintf (filebuf, "%d", getpid ());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -379,7 +379,7 @@ fhandler_process::fill_filebuf ()
|
|||
case PROCESS_CTTY:
|
||||
case PROCESS_PPID:
|
||||
{
|
||||
filebuf = (char *) crealloc (filebuf, bufalloc = 40);
|
||||
filebuf = (char *) crealloc_abort (filebuf, bufalloc = 40);
|
||||
int num;
|
||||
switch (fileid)
|
||||
{
|
||||
|
@ -442,7 +442,7 @@ fhandler_process::fill_filebuf ()
|
|||
case PROCESS_EXENAME:
|
||||
case PROCESS_EXE:
|
||||
{
|
||||
filebuf = (char *) crealloc (filebuf, bufalloc = CYG_MAX_PATH);
|
||||
filebuf = (char *) crealloc_abort (filebuf, bufalloc = CYG_MAX_PATH);
|
||||
if (p->process_state & PID_EXITED)
|
||||
strcpy (filebuf, "<defunct>");
|
||||
else
|
||||
|
@ -466,7 +466,7 @@ fhandler_process::fill_filebuf ()
|
|||
}
|
||||
case PROCESS_WINPID:
|
||||
{
|
||||
filebuf = (char *) crealloc (filebuf, bufalloc = 40);
|
||||
filebuf = (char *) crealloc_abort (filebuf, bufalloc = 40);
|
||||
__small_sprintf (filebuf, "%d\n", p->dwProcessId);
|
||||
filesize = strlen (filebuf);
|
||||
break;
|
||||
|
@ -474,7 +474,7 @@ fhandler_process::fill_filebuf ()
|
|||
case PROCESS_WINEXENAME:
|
||||
{
|
||||
int len = strlen (p->progname);
|
||||
filebuf = (char *) crealloc (filebuf, bufalloc = (len + 2));
|
||||
filebuf = (char *) crealloc_abort (filebuf, bufalloc = (len + 2));
|
||||
strcpy (filebuf, p->progname);
|
||||
filebuf[len] = '\n';
|
||||
filesize = len + 1;
|
||||
|
@ -482,25 +482,25 @@ fhandler_process::fill_filebuf ()
|
|||
}
|
||||
case PROCESS_STATUS:
|
||||
{
|
||||
filebuf = (char *) crealloc (filebuf, bufalloc = 2048);
|
||||
filebuf = (char *) crealloc_abort (filebuf, bufalloc = 2048);
|
||||
filesize = format_process_status (*p, filebuf, bufalloc);
|
||||
break;
|
||||
}
|
||||
case PROCESS_STAT:
|
||||
{
|
||||
filebuf = (char *) crealloc (filebuf, bufalloc = 2048);
|
||||
filebuf = (char *) crealloc_abort (filebuf, bufalloc = 2048);
|
||||
filesize = format_process_stat (*p, filebuf, bufalloc);
|
||||
break;
|
||||
}
|
||||
case PROCESS_STATM:
|
||||
{
|
||||
filebuf = (char *) crealloc (filebuf, bufalloc = 2048);
|
||||
filebuf = (char *) crealloc_abort (filebuf, bufalloc = 2048);
|
||||
filesize = format_process_statm (*p, filebuf, bufalloc);
|
||||
break;
|
||||
}
|
||||
case PROCESS_MAPS:
|
||||
{
|
||||
filebuf = (char *) crealloc (filebuf, bufalloc = 2048);
|
||||
filebuf = (char *) crealloc_abort (filebuf, bufalloc = 2048);
|
||||
filesize = format_process_maps (*p, filebuf, bufalloc);
|
||||
break;
|
||||
}
|
||||
|
@ -563,7 +563,7 @@ format_process_maps (_pinfo *p, char *&destbuf, size_t maxsize)
|
|||
st.st_ino = 0;
|
||||
}
|
||||
if (len + strlen (posix_modname) + 62 > maxsize - 1)
|
||||
destbuf = (char *) crealloc (destbuf, maxsize += 2048);
|
||||
destbuf = (char *) crealloc_abort (destbuf, maxsize += 2048);
|
||||
if (workingset)
|
||||
for (unsigned i = 1; i <= wset_size; ++i)
|
||||
{
|
||||
|
|
|
@ -592,7 +592,7 @@ fhandler_registry::fill_filebuf ()
|
|||
goto value_not_found;
|
||||
}
|
||||
bufalloc = size;
|
||||
filebuf = (char *) cmalloc (HEAP_BUF, bufalloc);
|
||||
filebuf = (char *) cmalloc_abort (HEAP_BUF, bufalloc);
|
||||
error =
|
||||
RegQueryValueEx (handle, value_name, NULL, NULL, (BYTE *) filebuf,
|
||||
&size);
|
||||
|
@ -609,7 +609,7 @@ fhandler_registry::fill_filebuf ()
|
|||
do
|
||||
{
|
||||
bufalloc += 1000;
|
||||
filebuf = (char *) crealloc (filebuf, bufalloc);
|
||||
filebuf = (char *) crealloc_abort (filebuf, bufalloc);
|
||||
size = bufalloc;
|
||||
error = RegQueryValueEx (handle, value_name, NULL, &type,
|
||||
(BYTE *) filebuf, &size);
|
||||
|
|
|
@ -601,7 +601,7 @@ fhandler_tty_slave::open (int flags, mode_t)
|
|||
fhandler_console::need_invisible ();
|
||||
|
||||
// FIXME: Do this better someday
|
||||
arch = (fhandler_tty_slave *) cmalloc (HEAP_ARCHETYPES, sizeof (*this));
|
||||
arch = (fhandler_tty_slave *) cmalloc_abort (HEAP_ARCHETYPES, sizeof (*this));
|
||||
*((fhandler_tty_slave **) cygheap->fdtab.add_archetype ()) = arch;
|
||||
archetype = arch;
|
||||
*arch = *this;
|
||||
|
@ -1127,7 +1127,7 @@ fhandler_pty_master::open (int flags, mode_t)
|
|||
set_open_status ();
|
||||
//
|
||||
// FIXME: Do this better someday
|
||||
fhandler_pty_master *arch = (fhandler_tty_master *) cmalloc (HEAP_ARCHETYPES, sizeof (*this));
|
||||
fhandler_pty_master *arch = (fhandler_tty_master *) cmalloc_abort (HEAP_ARCHETYPES, sizeof (*this));
|
||||
*((fhandler_pty_master **) cygheap->fdtab.add_archetype ()) = arch;
|
||||
archetype = arch;
|
||||
*arch = *this;
|
||||
|
|
|
@ -164,7 +164,7 @@ fhandler_virtual::dup (fhandler_base * child)
|
|||
if (!ret)
|
||||
{
|
||||
fhandler_virtual *fhproc_child = (fhandler_virtual *) child;
|
||||
fhproc_child->filebuf = (char *) cmalloc (HEAP_BUF, filesize);
|
||||
fhproc_child->filebuf = (char *) cmalloc_abort (HEAP_BUF, filesize);
|
||||
fhproc_child->bufalloc = fhproc_child->filesize = filesize;
|
||||
fhproc_child->position = position;
|
||||
memcpy (fhproc_child->filebuf, filebuf, filesize);
|
||||
|
|
|
@ -107,7 +107,7 @@ RedirectIAT (function_hook& fh, PIMAGE_IMPORT_DESCRIPTOR pImportDesc,
|
|||
hook_chain *hc;
|
||||
for (hc = &cygheap->hooks; hc->next; hc = hc->next)
|
||||
continue;
|
||||
hc->next = (hook_chain *) cmalloc (HEAP_1_HOOK, sizeof (hook_chain));
|
||||
hc->next = (hook_chain *) cmalloc_abort (HEAP_1_HOOK, sizeof (hook_chain));
|
||||
hc->next->loc = (void **) pi;
|
||||
hc->next->func = fh.hookfn;
|
||||
hc->next->next = NULL;
|
||||
|
|
|
@ -535,7 +535,7 @@ path_conv::set_normalized_path (const char *path_copy, bool strip_tail)
|
|||
normalized_path_size = n;
|
||||
else
|
||||
{
|
||||
normalized_path = (char *) cmalloc (HEAP_STR, n);
|
||||
normalized_path = (char *) cmalloc_abort (HEAP_STR, n);
|
||||
normalized_path_size = 0;
|
||||
}
|
||||
|
||||
|
@ -543,7 +543,7 @@ path_conv::set_normalized_path (const char *path_copy, bool strip_tail)
|
|||
}
|
||||
|
||||
PUNICODE_STRING
|
||||
get_nt_native_path (const char *path, UNICODE_STRING &upath)
|
||||
get_nt_native_path (const char *path, UNICODE_STRING& upath)
|
||||
{
|
||||
upath.Length = 0;
|
||||
if (path[0] == '/') /* special path w/o NT path representation. */
|
||||
|
@ -576,7 +576,7 @@ path_conv::get_nt_native_path ()
|
|||
{
|
||||
uni_path.Length = 0;
|
||||
uni_path.MaximumLength = (strlen (path) + 10) * sizeof (WCHAR);
|
||||
wide_path = (PWCHAR) cmalloc (HEAP_STR, uni_path.MaximumLength);
|
||||
wide_path = (PWCHAR) cmalloc_abort (HEAP_STR, uni_path.MaximumLength);
|
||||
uni_path.Buffer = wide_path;
|
||||
::get_nt_native_path (path, uni_path);
|
||||
}
|
||||
|
@ -4479,8 +4479,8 @@ skip_peb_storing:
|
|||
RtlAcquirePebLock ();
|
||||
pdir = &get_user_proc_parms ()->CurrentDirectoryName;
|
||||
RtlInitEmptyUnicodeString (&win32,
|
||||
(PWCHAR) crealloc (win32.Buffer,
|
||||
pdir->Length + 2),
|
||||
(PWCHAR) crealloc_abort (win32.Buffer,
|
||||
pdir->Length + 2),
|
||||
pdir->Length + 2);
|
||||
RtlCopyUnicodeString (&win32, pdir);
|
||||
RtlReleasePebLock ();
|
||||
|
@ -4504,8 +4504,8 @@ skip_peb_storing:
|
|||
else if (upath.Length > 3 * sizeof (WCHAR))
|
||||
upath.Length -= sizeof (WCHAR); /* Strip trailing backslash */
|
||||
RtlInitEmptyUnicodeString (&win32,
|
||||
(PWCHAR) crealloc (win32.Buffer,
|
||||
upath.Length + 2),
|
||||
(PWCHAR) crealloc_abort (win32.Buffer,
|
||||
upath.Length + 2),
|
||||
upath.Length + 2);
|
||||
RtlCopyUnicodeString (&win32, &upath);
|
||||
}
|
||||
|
@ -4531,7 +4531,7 @@ skip_peb_storing:
|
|||
posix_cwd = (const char *) alloca (PATH_MAX);
|
||||
mount_table->conv_to_posix_path (win32.Buffer, (char *) posix_cwd, 0);
|
||||
}
|
||||
posix = (char *) crealloc (posix, strlen (posix_cwd) + 1);
|
||||
posix = (char *) crealloc_abort (posix, strlen (posix_cwd) + 1);
|
||||
stpcpy (posix, posix_cwd);
|
||||
}
|
||||
|
||||
|
|
|
@ -604,7 +604,7 @@ _pinfo::commune_request (__uint32_t code, ...)
|
|||
res.s = NULL;
|
||||
else
|
||||
{
|
||||
res.s = (char *) cmalloc (HEAP_COMMUNE, n);
|
||||
res.s = (char *) cmalloc_abort (HEAP_COMMUNE, n);
|
||||
char *p;
|
||||
for (p = res.s; n && ReadFile (fromthem, p, n, &nr, NULL); p += nr, n -= nr)
|
||||
continue;
|
||||
|
@ -666,7 +666,7 @@ _pinfo::fd (int fd, size_t &n)
|
|||
if (cfd < 0)
|
||||
s = cstrdup ("");
|
||||
else
|
||||
s = cfd->get_proc_fd_name ((char *) cmalloc (HEAP_COMMUNE, CYG_MAX_PATH));
|
||||
s = cfd->get_proc_fd_name ((char *) cmalloc_abort (HEAP_COMMUNE, CYG_MAX_PATH));
|
||||
n = strlen (s) + 1;
|
||||
}
|
||||
return s;
|
||||
|
@ -692,7 +692,7 @@ _pinfo::fds (size_t &n)
|
|||
while ((fd = cfd.next ()) >= 0)
|
||||
n += sizeof (int);
|
||||
cfd.rewind ();
|
||||
s = (char *) cmalloc (HEAP_COMMUNE, n);
|
||||
s = (char *) cmalloc_abort (HEAP_COMMUNE, n);
|
||||
int *p = (int *) s;
|
||||
while ((fd = cfd.next ()) >= 0 && (char *) p - s < (int) n)
|
||||
*p++ = fd;
|
||||
|
@ -737,7 +737,7 @@ _pinfo::cwd (size_t& n)
|
|||
}
|
||||
else
|
||||
{
|
||||
s = (char *) cmalloc (HEAP_COMMUNE, CYG_MAX_PATH);
|
||||
s = (char *) cmalloc_abort (HEAP_COMMUNE, CYG_MAX_PATH);
|
||||
cygheap->cwd.get (s, 1, 1, CYG_MAX_PATH);
|
||||
n = strlen (s) + 1;
|
||||
}
|
||||
|
@ -762,7 +762,7 @@ _pinfo::cmdline (size_t& n)
|
|||
for (char **a = __argv; *a; a++)
|
||||
n += strlen (*a) + 1;
|
||||
char *p;
|
||||
p = s = (char *) cmalloc (HEAP_COMMUNE, n);
|
||||
p = s = (char *) cmalloc_abort (HEAP_COMMUNE, n);
|
||||
for (char **a = __argv; *a; a++)
|
||||
{
|
||||
strcpy (p, *a);
|
||||
|
|
|
@ -113,7 +113,7 @@ void __stdcall
|
|||
sigalloc ()
|
||||
{
|
||||
cygheap->sigs = global_sigs =
|
||||
(struct sigaction *) ccalloc (HEAP_SIGS, NSIG, sizeof (struct sigaction));
|
||||
(struct sigaction *) ccalloc_abort (HEAP_SIGS, NSIG, sizeof (struct sigaction));
|
||||
global_sigs[SIGSTOP].sa_flags = SA_RESTART | SA_NODEFER;
|
||||
}
|
||||
|
||||
|
|
|
@ -333,7 +333,7 @@ spawn_guts (const char * prog_arg, const char *const *argv,
|
|||
else
|
||||
chtype = PROC_EXEC;
|
||||
|
||||
moreinfo = (cygheap_exec_info *) ccalloc (HEAP_1_EXEC, 1, sizeof (cygheap_exec_info));
|
||||
moreinfo = (cygheap_exec_info *) ccalloc_abort (HEAP_1_EXEC, 1, sizeof (cygheap_exec_info));
|
||||
moreinfo->old_title = NULL;
|
||||
|
||||
/* CreateProcess takes one long string that is the command line (sigh).
|
||||
|
|
|
@ -446,7 +446,7 @@ cygheap_user::env_systemroot (const char *name, size_t namelen)
|
|||
int size = GetWindowsDirectory (NULL, 0);
|
||||
if (size > 0)
|
||||
{
|
||||
psystemroot = (char *) cmalloc (HEAP_STR, ++size);
|
||||
psystemroot = (char *) cmalloc_abort (HEAP_STR, ++size);
|
||||
size = GetWindowsDirectory (psystemroot, size);
|
||||
if (size <= 0)
|
||||
{
|
||||
|
|
|
@ -30,7 +30,7 @@ class av
|
|||
av (): argv (NULL) {}
|
||||
av (int ac_in, const char * const *av_in) : calloced (0), argc (ac_in), win16_exe (false)
|
||||
{
|
||||
argv = (char **) cmalloc (HEAP_1_ARGV, (argc + 5) * sizeof (char *));
|
||||
argv = (char **) cmalloc_abort (HEAP_1_ARGV, (argc + 5) * sizeof (char *));
|
||||
memcpy (argv, av_in, (argc + 1) * sizeof (char *));
|
||||
}
|
||||
void *operator new (size_t, void *p) __attribute__ ((nothrow)) {return p;}
|
||||
|
|
Loading…
Reference in New Issue