--- trunk/src/console.c 2007/10/08 16:22:20 41 +++ trunk/src/console.c 2007/10/08 16:22:32 42 @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * - * $Id: console.c,v 1.22 2006/12/30 13:30:51 debug Exp $ + * $Id: console.c,v 1.26 2007/06/15 18:07:33 debug Exp $ * * Generic console support functions. * @@ -70,12 +70,11 @@ #include #include #include +#include #include "console.h" #include "emul.h" #include "machine.h" -#include "memory.h" -#include "misc.h" #include "settings.h" @@ -205,11 +204,7 @@ /* printf("filedesB = %i,%i\n", filedesB[0], filedesB[1]); */ /* NOTE/warning: Hardcoded max nr of args! */ - a = malloc(sizeof(char *) * 20); - if (a == NULL) { - fprintf(stderr, "start_xterm(): out of memory\n"); - exit(1); - } + CHECK_ALLOCATION(a = malloc(sizeof(char *) * 20)); a[0] = getenv("XTERM"); if (a[0] == NULL) @@ -219,13 +214,13 @@ a[3] = "-title"; mlen = strlen(console_handles[handle].name) + strlen(console_handles[handle].machine_name) + 30; - a[4] = malloc(mlen); + CHECK_ALLOCATION(a[4] = malloc(mlen)); snprintf(a[4], mlen, "GXemul: %s %s", console_handles[handle].machine_name, console_handles[handle].name); a[5] = "-e"; a[6] = progname; - a[7] = malloc(80); + CHECK_ALLOCATION(a[7] = malloc(80)); snprintf(a[7], 80, "-WW@S%i,%i", filedes[0], filedesB[1]); a[8] = NULL; @@ -616,12 +611,9 @@ if (found_free == -1) { /* Let's realloc console_handles[], to make room for the new one: */ - console_handles = realloc(console_handles, sizeof( - struct console_handle) * (n_console_handles + 1)); - if (console_handles == NULL) { - printf("console_new_handle(): out of memory\n"); - exit(1); - } + CHECK_ALLOCATION(console_handles = + realloc(console_handles, sizeof( + struct console_handle) * (n_console_handles + 1))); found_free = n_console_handles; n_console_handles ++; } @@ -631,11 +623,7 @@ chp->in_use = 1; chp->machine_name = ""; - chp->name = strdup(name); - if (chp->name == NULL) { - printf("console_new_handle(): out of memory\n"); - exit(1); - } + CHECK_ALLOCATION(chp->name = strdup(name)); *handlep = found_free; return chp; @@ -685,12 +673,14 @@ chp->in_use_for_input = 0; } - if (machine->machine_name != NULL) - chp->machine_name = strdup(machine->machine_name); - else - chp->machine_name = strdup(""); + if (machine->machine_name != NULL) { + CHECK_ALLOCATION(chp->machine_name = + strdup(machine->machine_name)); + } else { + CHECK_ALLOCATION(chp->machine_name = strdup("")); + } - chp->name = strdup(consolename); + CHECK_ALLOCATION(chp->name = strdup(consolename)); if (allow_slaves) chp->using_xterm = USING_XTERM_BUT_NOT_YET_OPEN; @@ -725,8 +715,8 @@ chp = console_new_handle(consolename, &handle); chp->inputonly = 1; chp->in_use_for_input = use_for_input; - chp->machine_name = strdup(machine->name); - chp->name = strdup(consolename); + CHECK_ALLOCATION(chp->machine_name = strdup(machine->name)); + CHECK_ALLOCATION(chp->name = strdup(consolename)); return handle; }