From 9194e3beb7170c7a3db7391f005e6ab0aabd180d Mon Sep 17 00:00:00 2001 From: Michael Santos Date: Thu, 28 Jan 2016 11:11:45 -0500 Subject: erts/common: check for OOM on Windows Fix the command line tools to abort on allocation failures when run on Windows. Modify the malloc() wrapper to consistently return void* across all the tools. --- erts/etc/common/ct_run.c | 24 ++++++++++++++++++------ erts/etc/common/dialyzer.c | 24 ++++++++++++++++++------ erts/etc/common/erlc.c | 24 ++++++++++++++++++------ erts/etc/common/escript.c | 24 ++++++++++++++++++------ erts/etc/common/inet_gethost.c | 2 +- erts/etc/common/typer.c | 24 ++++++++++++++++++------ 6 files changed, 91 insertions(+), 31 deletions(-) (limited to 'erts') diff --git a/erts/etc/common/ct_run.c b/erts/etc/common/ct_run.c index 548514ee6c..03ab22d1a1 100644 --- a/erts/etc/common/ct_run.c +++ b/erts/etc/common/ct_run.c @@ -81,13 +81,14 @@ static int eargc; /* Number of arguments in eargv. */ */ static void error(char* format, ...); -static char* emalloc(size_t size); +static void* emalloc(size_t size); static char* strsave(char* string); static void push_words(char* src); static int run_erlang(char* name, char** argv); static char* get_default_emulator(char* progname); #ifdef __WIN32__ static char* possibly_quote(char* arg); +static void* erealloc(void *p, size_t size); #endif /* @@ -141,10 +142,10 @@ int main(int argc, char** argv) int i; int len; /* Convert argv to utf8 */ - argv = malloc((argc+1) * sizeof(char*)); + argv = emalloc((argc+1) * sizeof(char*)); for (i=0; idata_present = CreateEvent(NULL, TRUE, FALSE,NULL); if (tmp->data_present == NULL) { free(tmp); diff --git a/erts/etc/common/typer.c b/erts/etc/common/typer.c index 0aa0996808..7f08050cc6 100644 --- a/erts/etc/common/typer.c +++ b/erts/etc/common/typer.c @@ -63,13 +63,14 @@ static int eargc; /* Number of arguments in eargv. */ */ static void error(char* format, ...); -static char* emalloc(size_t size); +static void* emalloc(size_t size); static char* strsave(char* string); static void push_words(char* src); static int run_erlang(char* name, char** argv); static char* get_default_emulator(char* progname); #ifdef __WIN32__ static char* possibly_quote(char* arg); +static void* erealloc(void *p, size_t size); #endif /* @@ -118,10 +119,10 @@ main(int argc, char** argv) int i; int len; /* Convert argv to utf8 */ - argv = malloc((argc+1) * sizeof(char*)); + argv = emalloc((argc+1) * sizeof(char*)); for (i=0; i