From 46d33884f2f1061ae1a77c26928f97d573e57c6c Mon Sep 17 00:00:00 2001 From: rcyeske Date: Fri, 2 Mar 2001 06:06:23 +0000 Subject: * ratpoison.h (xmalloc, xrealloc, fatal): Prototype. * main.c (xmalloc): Move here from sbuf.c. (xrealloc): Likewise. (fatal): Likewise. * number.c (find_empty_cell): Use xrealloc, remove error check. (init_numbers): Likewise. * manage.c (get_window_name): Likewise. * main.c (main): Likewise. * list.c (add_to_window_list): Likewise. (add_to_window_list): Likewise. * events.c (handle_key): Likewise. * input.c (keysym_to_string): Likewise. (get_more_input): Use xrealloc, remove error check. * main.c (read_rc_file): Take a file pointer rather than a filename. (read_startup_files): If ~/.ratpoisonrc is not readable try /etc/ratpoisonrc. --- src/list.c | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) (limited to 'src/list.c') diff --git a/src/list.c b/src/list.c index 12b5bbb..2192b1e 100644 --- a/src/list.c +++ b/src/list.c @@ -47,12 +47,8 @@ add_to_window_list (screen_info *s, Window w) { rp_window *new_window; - new_window = malloc (sizeof (rp_window)); - if (new_window == NULL) - { - PRINT_ERROR ("Out of memory!\n"); - exit (EXIT_FAILURE); - } + new_window = xmalloc (sizeof (rp_window)); + new_window->w = w; new_window->scr = s; new_window->last_access = 0; @@ -69,11 +65,8 @@ add_to_window_list (screen_info *s, Window w) XSelectInput (dpy, new_window->w, PropertyChangeMask | ColormapChangeMask); - if ((new_window->name = malloc (strlen ("Unnamed") + 1)) == NULL) - { - PRINT_ERROR ("Out of memory!\n"); - exit (EXIT_FAILURE); - } + new_window->name = xmalloc (strlen ("Unnamed") + 1); + strcpy (new_window->name, "Unnamed"); /* Add the window to the end of the unmapped list. */ @@ -123,15 +116,8 @@ set_current_window (rp_window *win) void init_window_list () { - rp_mapped_window_sentinel = malloc (sizeof (rp_window)); - rp_unmapped_window_sentinel = malloc (sizeof (rp_window)); - - if (!rp_mapped_window_sentinel - || !rp_unmapped_window_sentinel) - { - PRINT_ERROR ("Out of memory!\n"); - exit (EXIT_FAILURE); - } + rp_mapped_window_sentinel = xmalloc (sizeof (rp_window)); + rp_unmapped_window_sentinel = xmalloc (sizeof (rp_window)); rp_mapped_window_sentinel->next = rp_mapped_window_sentinel; rp_mapped_window_sentinel->prev = rp_mapped_window_sentinel; -- cgit v1.2.3