From: Dmitry Antipov Date: Thu, 15 Aug 2013 05:23:40 +0000 (+0400) Subject: * term.c (get_named_tty, create_tty_output, tty_free_frame_resources) X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~1686^2~242 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=9c25330708e49ddaeb71f16a65cdc1b51be2a27d;p=emacs.git * term.c (get_named_tty, create_tty_output, tty_free_frame_resources) (tty_free_frame_resources, delete_tty): Prefer eassert to emacs_abort. * image.c (make_image_cache): For struct image_cache, prefer xmalloc to xzalloc and so avoid redundant call to memset. * xterm.c (x_term_init): Avoid unnecessary initializations of dpyinfo members because it is allocated with xzalloc and so already zeroed. --- diff --git a/src/ChangeLog b/src/ChangeLog index 43e9bca061b..0d3982618b7 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,12 @@ +2013-08-15 Dmitry Antipov + + * term.c (get_named_tty, create_tty_output, tty_free_frame_resources) + (tty_free_frame_resources, delete_tty): Prefer eassert to emacs_abort. + * image.c (make_image_cache): For struct image_cache, prefer xmalloc + to xzalloc and so avoid redundant call to memset. + * xterm.c (x_term_init): Avoid unnecessary initializations of dpyinfo + members because it is allocated with xzalloc and so already zeroed. + 2013-08-14 Ken Brown * gmalloc.c (memalign) [CYGWIN]: Rename to emacs_memalign diff --git a/src/image.c b/src/image.c index f71ba211d44..8d969a6f9c6 100644 --- a/src/image.c +++ b/src/image.c @@ -1360,14 +1360,12 @@ static void cache_image (struct frame *f, struct image *img); struct image_cache * make_image_cache (void) { - struct image_cache *c = xzalloc (sizeof *c); - int size; - - size = 50; - c->images = xmalloc (size * sizeof *c->images); - c->size = size; - size = IMAGE_CACHE_BUCKETS_SIZE * sizeof *c->buckets; - c->buckets = xzalloc (size); + struct image_cache *c = xmalloc (sizeof *c); + + c->size = 50; + c->used = c->refcount = 0; + c->images = xmalloc (c->size * sizeof *c->images); + c->buckets = xzalloc (IMAGE_CACHE_BUCKETS_SIZE * sizeof *c->buckets); return c; } diff --git a/src/term.c b/src/term.c index fb69aefbe7a..2966466aed2 100644 --- a/src/term.c +++ b/src/term.c @@ -2233,8 +2233,7 @@ get_named_tty (const char *name) { struct terminal *t; - if (!name) - emacs_abort (); + eassert (name); for (t = terminal_list; t; t = t->next_terminal) { @@ -2786,8 +2785,7 @@ create_tty_output (struct frame *f) { struct tty_output *t = xzalloc (sizeof *t); - if (! FRAME_TERMCAP_P (f)) - emacs_abort (); + eassert (FRAME_TERMCAP_P (f)); t->display_info = FRAME_TERMINAL (f)->display_info.tty; @@ -2799,8 +2797,7 @@ create_tty_output (struct frame *f) static void tty_free_frame_resources (struct frame *f) { - if (! FRAME_TERMCAP_P (f)) - emacs_abort (); + eassert (FRAME_TERMCAP_P (f)); if (FRAME_FACE_CACHE (f)) free_frame_faces (f); @@ -2815,8 +2812,7 @@ tty_free_frame_resources (struct frame *f) static void tty_free_frame_resources (struct frame *f) { - if (! FRAME_TERMCAP_P (f) && ! FRAME_MSDOS_P (f)) - emacs_abort (); + eassert (FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f)); if (FRAME_FACE_CACHE (f)) free_frame_faces (f); @@ -3443,8 +3439,7 @@ delete_tty (struct terminal *terminal) if (!terminal->name) return; - if (terminal->type != output_termcap) - emacs_abort (); + eassert (terminal->type == output_termcap); tty = terminal->display_info.tty; diff --git a/src/xterm.c b/src/xterm.c index 9e1e32a2faf..b5c5a5cb584 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -10080,33 +10080,15 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) select_visual (dpyinfo); dpyinfo->cmap = DefaultColormapOfScreen (dpyinfo->screen); dpyinfo->root_window = RootWindowOfScreen (dpyinfo->screen); - dpyinfo->client_leader_window = 0; - dpyinfo->grabbed = 0; - dpyinfo->reference_count = 0; dpyinfo->icon_bitmap_id = -1; - dpyinfo->n_fonts = 0; - dpyinfo->bitmaps = 0; - dpyinfo->bitmaps_size = 0; - dpyinfo->bitmaps_last = 0; - dpyinfo->scratch_cursor_gc = 0; - hlinfo->mouse_face_mouse_frame = 0; hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1; hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1; hlinfo->mouse_face_face_id = DEFAULT_FACE_ID; hlinfo->mouse_face_window = Qnil; hlinfo->mouse_face_overlay = Qnil; - hlinfo->mouse_face_mouse_x = hlinfo->mouse_face_mouse_y = 0; - hlinfo->mouse_face_defer = 0; - hlinfo->mouse_face_hidden = 0; - dpyinfo->x_focus_frame = 0; - dpyinfo->x_focus_event_frame = 0; - dpyinfo->x_highlight_frame = 0; dpyinfo->wm_type = X_WMTYPE_UNKNOWN; /* See if we can construct pixel values from RGB values. */ - dpyinfo->red_bits = dpyinfo->blue_bits = dpyinfo->green_bits = 0; - dpyinfo->red_offset = dpyinfo->blue_offset = dpyinfo->green_offset = 0; - if (dpyinfo->visual->class == TrueColor) { get_bits_and_offset (dpyinfo->visual->red_mask, @@ -10267,14 +10249,9 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) } dpyinfo->x_dnd_atoms_size = 8; - dpyinfo->x_dnd_atoms_length = 0; dpyinfo->x_dnd_atoms = xmalloc (sizeof *dpyinfo->x_dnd_atoms * dpyinfo->x_dnd_atoms_size); - dpyinfo->net_supported_atoms = NULL; - dpyinfo->nr_net_supported_atoms = 0; - dpyinfo->net_supported_window = 0; - connection = ConnectionNumber (dpyinfo->display); dpyinfo->connection = connection; dpyinfo->gray