diff options
| author | Dmitry Antipov | 2012-06-26 18:41:01 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2012-06-26 18:41:01 +0400 |
| commit | 62efea5e881407a178c5c291575facc17dca8a3f (patch) | |
| tree | 03224f091836b782bea0e86c76d9135d9a5f86bf /src | |
| parent | 995a55159dc4b4831e45fe9827a99cadad1bcbd3 (diff) | |
| download | emacs-62efea5e881407a178c5c291575facc17dca8a3f.tar.gz emacs-62efea5e881407a178c5c291575facc17dca8a3f.zip | |
* alloc.c (allocate_window): Zero out non-Lisp part of newly
allocated window.
(allocate_process): Likewise for new process.
(allocate_terminal): Changed to use offsetof.
(allocate_frame): Likewise.
* frame.c (make_frame): Omit redundant initialization.
* window.c (make_parent_window): Use memset.
(make_window): Omit redundant initialization.
* process.c (make_process): Omit redundant initialization.
* terminal.c (create_terminal): Likewise.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 13 | ||||
| -rw-r--r-- | src/alloc.c | 39 | ||||
| -rw-r--r-- | src/frame.c | 58 | ||||
| -rw-r--r-- | src/process.c | 29 | ||||
| -rw-r--r-- | src/terminal.c | 4 | ||||
| -rw-r--r-- | src/window.c | 44 |
6 files changed, 60 insertions, 127 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 9c6bf77785b..c7922ee8a8c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,18 @@ | |||
| 1 | 2012-06-26 Dmitry Antipov <dmantipov@yandex.ru> | 1 | 2012-06-26 Dmitry Antipov <dmantipov@yandex.ru> |
| 2 | 2 | ||
| 3 | * alloc.c (allocate_window): Zero out non-Lisp part of newly | ||
| 4 | allocated window. | ||
| 5 | (allocate_process): Likewise for new process. | ||
| 6 | (allocate_terminal): Changed to use offsetof. | ||
| 7 | (allocate_frame): Likewise. | ||
| 8 | * frame.c (make_frame): Omit redundant initialization. | ||
| 9 | * window.c (make_parent_window): Use memset. | ||
| 10 | (make_window): Omit redundant initialization. | ||
| 11 | * process.c (make_process): Omit redundant initialization. | ||
| 12 | * terminal.c (create_terminal): Likewise. | ||
| 13 | |||
| 14 | 2012-06-26 Dmitry Antipov <dmantipov@yandex.ru> | ||
| 15 | |||
| 3 | * term.c (delete_tty): Remove redundant call to memset. | 16 | * term.c (delete_tty): Remove redundant call to memset. |
| 4 | 17 | ||
| 5 | 2012-06-26 Dmitry Antipov <dmantipov@yandex.ru> | 18 | 2012-06-26 Dmitry Antipov <dmantipov@yandex.ru> |
diff --git a/src/alloc.c b/src/alloc.c index 6f7cc968b81..7f9574d43d1 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -3278,44 +3278,53 @@ allocate_hash_table (void) | |||
| 3278 | return ALLOCATE_PSEUDOVECTOR (struct Lisp_Hash_Table, count, PVEC_HASH_TABLE); | 3278 | return ALLOCATE_PSEUDOVECTOR (struct Lisp_Hash_Table, count, PVEC_HASH_TABLE); |
| 3279 | } | 3279 | } |
| 3280 | 3280 | ||
| 3281 | |||
| 3282 | struct window * | 3281 | struct window * |
| 3283 | allocate_window (void) | 3282 | allocate_window (void) |
| 3284 | { | 3283 | { |
| 3285 | return ALLOCATE_PSEUDOVECTOR (struct window, current_matrix, PVEC_WINDOW); | 3284 | struct window *w; |
| 3286 | } | ||
| 3287 | 3285 | ||
| 3286 | w = ALLOCATE_PSEUDOVECTOR (struct window, current_matrix, PVEC_WINDOW); | ||
| 3287 | /* Users assumes that non-Lisp data is zeroed. */ | ||
| 3288 | memset (&w->current_matrix, 0, | ||
| 3289 | sizeof (*w) - offsetof (struct window, current_matrix)); | ||
| 3290 | return w; | ||
| 3291 | } | ||
| 3288 | 3292 | ||
| 3289 | struct terminal * | 3293 | struct terminal * |
| 3290 | allocate_terminal (void) | 3294 | allocate_terminal (void) |
| 3291 | { | 3295 | { |
| 3292 | struct terminal *t = ALLOCATE_PSEUDOVECTOR (struct terminal, | 3296 | struct terminal *t; |
| 3293 | next_terminal, PVEC_TERMINAL); | ||
| 3294 | /* Zero out the non-GC'd fields. FIXME: This should be made unnecessary. */ | ||
| 3295 | memset (&t->next_terminal, 0, | ||
| 3296 | (char*) (t + 1) - (char*) &t->next_terminal); | ||
| 3297 | 3297 | ||
| 3298 | t = ALLOCATE_PSEUDOVECTOR (struct terminal, next_terminal, PVEC_TERMINAL); | ||
| 3299 | /* Users assumes that non-Lisp data is zeroed. */ | ||
| 3300 | memset (&t->next_terminal, 0, | ||
| 3301 | sizeof (*t) - offsetof (struct terminal, next_terminal)); | ||
| 3298 | return t; | 3302 | return t; |
| 3299 | } | 3303 | } |
| 3300 | 3304 | ||
| 3301 | struct frame * | 3305 | struct frame * |
| 3302 | allocate_frame (void) | 3306 | allocate_frame (void) |
| 3303 | { | 3307 | { |
| 3304 | struct frame *f = ALLOCATE_PSEUDOVECTOR (struct frame, | 3308 | struct frame *f; |
| 3305 | face_cache, PVEC_FRAME); | 3309 | |
| 3306 | /* Zero out the non-GC'd fields. FIXME: This should be made unnecessary. */ | 3310 | f = ALLOCATE_PSEUDOVECTOR (struct frame, face_cache, PVEC_FRAME); |
| 3311 | /* Users assumes that non-Lisp data is zeroed. */ | ||
| 3307 | memset (&f->face_cache, 0, | 3312 | memset (&f->face_cache, 0, |
| 3308 | (char *) (f + 1) - (char *) &f->face_cache); | 3313 | sizeof (*f) - offsetof (struct frame, face_cache)); |
| 3309 | return f; | 3314 | return f; |
| 3310 | } | 3315 | } |
| 3311 | 3316 | ||
| 3312 | |||
| 3313 | struct Lisp_Process * | 3317 | struct Lisp_Process * |
| 3314 | allocate_process (void) | 3318 | allocate_process (void) |
| 3315 | { | 3319 | { |
| 3316 | return ALLOCATE_PSEUDOVECTOR (struct Lisp_Process, pid, PVEC_PROCESS); | 3320 | struct Lisp_Process *p; |
| 3317 | } | ||
| 3318 | 3321 | ||
| 3322 | p = ALLOCATE_PSEUDOVECTOR (struct Lisp_Process, pid, PVEC_PROCESS); | ||
| 3323 | /* Users assumes that non-Lisp data is zeroed. */ | ||
| 3324 | memset (&p->pid, 0, | ||
| 3325 | sizeof (*p) - offsetof (struct Lisp_Process, pid)); | ||
| 3326 | return p; | ||
| 3327 | } | ||
| 3319 | 3328 | ||
| 3320 | DEFUN ("make-vector", Fmake_vector, Smake_vector, 2, 2, 0, | 3329 | DEFUN ("make-vector", Fmake_vector, Smake_vector, 2, 2, 0, |
| 3321 | doc: /* Return a newly created vector of length LENGTH, with each element being INIT. | 3330 | doc: /* Return a newly created vector of length LENGTH, with each element being INIT. |
diff --git a/src/frame.c b/src/frame.c index fc52b07923d..b048327abfb 100644 --- a/src/frame.c +++ b/src/frame.c | |||
| @@ -267,63 +267,23 @@ make_frame (int mini_p) | |||
| 267 | f = allocate_frame (); | 267 | f = allocate_frame (); |
| 268 | XSETFRAME (frame, f); | 268 | XSETFRAME (frame, f); |
| 269 | 269 | ||
| 270 | f->desired_matrix = 0; | 270 | /* Initialize Lisp data. Note that allocate_frame initializes all |
| 271 | f->current_matrix = 0; | 271 | Lisp data to nil, so do it only for slots which should not be nil. */ |
| 272 | f->desired_pool = 0; | 272 | f->tool_bar_position = Qtop; |
| 273 | f->current_pool = 0; | 273 | |
| 274 | f->glyphs_initialized_p = 0; | 274 | /* Initialize non-Lisp data. Note that allocate_frame zeroes out all |
| 275 | f->decode_mode_spec_buffer = 0; | 275 | non-Lisp data, so do it only for slots which should not be zero. |
| 276 | f->visible = 0; | 276 | To avoid subtle bugs and for the sake of readability, it's better to |
| 277 | f->async_visible = 0; | 277 | initialize enum members explicitly even if their values are zero. */ |
| 278 | f->output_data.nothing = 0; | ||
| 279 | f->iconified = 0; | ||
| 280 | f->async_iconified = 0; | ||
| 281 | f->wants_modeline = 1; | 278 | f->wants_modeline = 1; |
| 282 | f->auto_raise = 0; | ||
| 283 | f->auto_lower = 0; | ||
| 284 | f->no_split = 0; | ||
| 285 | f->garbaged = 1; | 279 | f->garbaged = 1; |
| 286 | f->has_minibuffer = mini_p; | 280 | f->has_minibuffer = mini_p; |
| 287 | f->focus_frame = Qnil; | ||
| 288 | f->explicit_name = 0; | ||
| 289 | f->can_have_scroll_bars = 0; | ||
| 290 | f->vertical_scroll_bar_type = vertical_scroll_bar_none; | 281 | f->vertical_scroll_bar_type = vertical_scroll_bar_none; |
| 291 | f->param_alist = Qnil; | ||
| 292 | f->scroll_bars = Qnil; | ||
| 293 | f->condemned_scroll_bars = Qnil; | ||
| 294 | f->face_alist = Qnil; | ||
| 295 | f->face_cache = NULL; | ||
| 296 | f->menu_bar_items = Qnil; | ||
| 297 | f->menu_bar_vector = Qnil; | ||
| 298 | f->menu_bar_items_used = 0; | ||
| 299 | f->buffer_predicate = Qnil; | ||
| 300 | f->buffer_list = Qnil; | ||
| 301 | f->buried_buffer_list = Qnil; | ||
| 302 | f->namebuf = 0; | ||
| 303 | f->title = Qnil; | ||
| 304 | f->menu_bar_window = Qnil; | ||
| 305 | f->tool_bar_window = Qnil; | ||
| 306 | f->tool_bar_items = Qnil; | ||
| 307 | f->tool_bar_position = Qtop; | ||
| 308 | f->desired_tool_bar_string = f->current_tool_bar_string = Qnil; | ||
| 309 | f->n_tool_bar_items = 0; | ||
| 310 | f->left_fringe_width = f->right_fringe_width = 0; | ||
| 311 | f->fringe_cols = 0; | ||
| 312 | f->menu_bar_lines = 0; | ||
| 313 | f->tool_bar_lines = 0; | ||
| 314 | f->scroll_bar_actual_width = 0; | ||
| 315 | f->border_width = 0; | ||
| 316 | f->internal_border_width = 0; | ||
| 317 | f->column_width = 1; /* !FRAME_WINDOW_P value */ | 282 | f->column_width = 1; /* !FRAME_WINDOW_P value */ |
| 318 | f->line_height = 1; /* !FRAME_WINDOW_P value */ | 283 | f->line_height = 1; /* !FRAME_WINDOW_P value */ |
| 319 | f->x_pixels_diff = f->y_pixels_diff = 0; | ||
| 320 | #ifdef HAVE_WINDOW_SYSTEM | 284 | #ifdef HAVE_WINDOW_SYSTEM |
| 321 | f->want_fullscreen = FULLSCREEN_NONE; | 285 | f->want_fullscreen = FULLSCREEN_NONE; |
| 322 | #endif | 286 | #endif |
| 323 | f->size_hint_flags = 0; | ||
| 324 | f->win_gravity = 0; | ||
| 325 | f->font_driver_list = NULL; | ||
| 326 | f->font_data_list = NULL; | ||
| 327 | 287 | ||
| 328 | root_window = make_window (); | 288 | root_window = make_window (); |
| 329 | if (mini_p) | 289 | if (mini_p) |
| @@ -399,8 +359,6 @@ make_frame (int mini_p) | |||
| 399 | ++window_select_count; | 359 | ++window_select_count; |
| 400 | XSETFASTINT (XWINDOW (f->selected_window)->use_time, window_select_count); | 360 | XSETFASTINT (XWINDOW (f->selected_window)->use_time, window_select_count); |
| 401 | 361 | ||
| 402 | f->default_face_done_p = 0; | ||
| 403 | |||
| 404 | return f; | 362 | return f; |
| 405 | } | 363 | } |
| 406 | 364 | ||
diff --git a/src/process.c b/src/process.c index e39710078d2..1508e4b13fc 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -625,35 +625,18 @@ make_process (Lisp_Object name) | |||
| 625 | printmax_t i; | 625 | printmax_t i; |
| 626 | 626 | ||
| 627 | p = allocate_process (); | 627 | p = allocate_process (); |
| 628 | 628 | /* Initialize Lisp data. Note that allocate_process initializes all | |
| 629 | p->infd = -1; | 629 | Lisp data to nil, so do it only for slots which should not be nil. */ |
| 630 | p->outfd = -1; | ||
| 631 | p->tick = 0; | ||
| 632 | p->update_tick = 0; | ||
| 633 | p->pid = 0; | ||
| 634 | p->pty_flag = 0; | ||
| 635 | p->raw_status_new = 0; | ||
| 636 | p->status = Qrun; | 630 | p->status = Qrun; |
| 637 | p->mark = Fmake_marker (); | 631 | p->mark = Fmake_marker (); |
| 638 | p->kill_without_query = 0; | ||
| 639 | p->write_queue = Qnil; | ||
| 640 | 632 | ||
| 641 | #ifdef ADAPTIVE_READ_BUFFERING | 633 | /* Initialize non-Lisp data. Note that allocate_process zeroes out all |
| 642 | p->adaptive_read_buffering = 0; | 634 | non-Lisp data, so do it only for slots which should not be zero. */ |
| 643 | p->read_output_delay = 0; | 635 | p->infd = -1; |
| 644 | p->read_output_skip = 0; | 636 | p->outfd = -1; |
| 645 | #endif | ||
| 646 | 637 | ||
| 647 | #ifdef HAVE_GNUTLS | 638 | #ifdef HAVE_GNUTLS |
| 648 | p->gnutls_initstage = GNUTLS_STAGE_EMPTY; | 639 | p->gnutls_initstage = GNUTLS_STAGE_EMPTY; |
| 649 | /* Default log level. */ | ||
| 650 | p->gnutls_log_level = 0; | ||
| 651 | /* GnuTLS handshakes attempted for this connection. */ | ||
| 652 | p->gnutls_handshakes_tried = 0; | ||
| 653 | p->gnutls_p = 0; | ||
| 654 | p->gnutls_state = NULL; | ||
| 655 | p->gnutls_x509_cred = NULL; | ||
| 656 | p->gnutls_anon_cred = NULL; | ||
| 657 | #endif | 640 | #endif |
| 658 | 641 | ||
| 659 | /* If name is already in use, modify it until it is unused. */ | 642 | /* If name is already in use, modify it until it is unused. */ |
diff --git a/src/terminal.c b/src/terminal.c index 9579d1dbd66..a3cae585d9a 100644 --- a/src/terminal.c +++ b/src/terminal.c | |||
| @@ -225,7 +225,6 @@ create_terminal (void) | |||
| 225 | struct terminal *terminal = allocate_terminal (); | 225 | struct terminal *terminal = allocate_terminal (); |
| 226 | Lisp_Object terminal_coding, keyboard_coding; | 226 | Lisp_Object terminal_coding, keyboard_coding; |
| 227 | 227 | ||
| 228 | terminal->name = NULL; | ||
| 229 | terminal->next_terminal = terminal_list; | 228 | terminal->next_terminal = terminal_list; |
| 230 | terminal_list = terminal; | 229 | terminal_list = terminal; |
| 231 | 230 | ||
| @@ -255,9 +254,6 @@ create_terminal (void) | |||
| 255 | setup_coding_system (keyboard_coding, terminal->keyboard_coding); | 254 | setup_coding_system (keyboard_coding, terminal->keyboard_coding); |
| 256 | setup_coding_system (terminal_coding, terminal->terminal_coding); | 255 | setup_coding_system (terminal_coding, terminal->terminal_coding); |
| 257 | 256 | ||
| 258 | terminal->param_alist = Qnil; | ||
| 259 | terminal->charset_list = Qnil; | ||
| 260 | terminal->Vselection_alist = Qnil; | ||
| 261 | return terminal; | 257 | return terminal; |
| 262 | } | 258 | } |
| 263 | 259 | ||
diff --git a/src/window.c b/src/window.c index 9420d733bc1..05749c12bb9 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -3242,13 +3242,12 @@ make_parent_window (Lisp_Object window, int horflag) | |||
| 3242 | { | 3242 | { |
| 3243 | Lisp_Object parent; | 3243 | Lisp_Object parent; |
| 3244 | register struct window *o, *p; | 3244 | register struct window *o, *p; |
| 3245 | int i; | ||
| 3246 | 3245 | ||
| 3247 | o = XWINDOW (window); | 3246 | o = XWINDOW (window); |
| 3248 | p = allocate_window (); | 3247 | p = allocate_window (); |
| 3249 | for (i = 0; i < VECSIZE (struct window); ++i) | 3248 | memcpy ((char *) p + sizeof (struct vectorlike_header), |
| 3250 | ((struct Lisp_Vector *) p)->contents[i] | 3249 | (char *) o + sizeof (struct vectorlike_header), |
| 3251 | = ((struct Lisp_Vector *) o)->contents[i]; | 3250 | sizeof (Lisp_Object) * VECSIZE (struct window)); |
| 3252 | XSETWINDOW (parent, p); | 3251 | XSETWINDOW (parent, p); |
| 3253 | 3252 | ||
| 3254 | ++sequence_number; | 3253 | ++sequence_number; |
| @@ -3277,10 +3276,8 @@ make_window (void) | |||
| 3277 | register struct window *w; | 3276 | register struct window *w; |
| 3278 | 3277 | ||
| 3279 | w = allocate_window (); | 3278 | w = allocate_window (); |
| 3280 | /* Initialize all Lisp data. */ | 3279 | /* Initialize Lisp data. Note that allocate_window initializes all |
| 3281 | w->frame = Qnil; | 3280 | Lisp data to nil, so do it only for slots which should not be nil. */ |
| 3282 | w->mini = 0; | ||
| 3283 | w->next = w->prev = w->hchild = w->vchild = w->parent = Qnil; | ||
| 3284 | XSETFASTINT (w->left_col, 0); | 3281 | XSETFASTINT (w->left_col, 0); |
| 3285 | XSETFASTINT (w->top_line, 0); | 3282 | XSETFASTINT (w->top_line, 0); |
| 3286 | XSETFASTINT (w->total_lines, 0); | 3283 | XSETFASTINT (w->total_lines, 0); |
| @@ -3289,47 +3286,24 @@ make_window (void) | |||
| 3289 | w->normal_cols = make_float (1.0); | 3286 | w->normal_cols = make_float (1.0); |
| 3290 | XSETFASTINT (w->new_total, 0); | 3287 | XSETFASTINT (w->new_total, 0); |
| 3291 | XSETFASTINT (w->new_normal, 0); | 3288 | XSETFASTINT (w->new_normal, 0); |
| 3292 | w->buffer = Qnil; | ||
| 3293 | w->start = Fmake_marker (); | 3289 | w->start = Fmake_marker (); |
| 3294 | w->pointm = Fmake_marker (); | 3290 | w->pointm = Fmake_marker (); |
| 3295 | w->force_start = w->optional_new_start = 0; | ||
| 3296 | XSETFASTINT (w->hscroll, 0); | 3291 | XSETFASTINT (w->hscroll, 0); |
| 3297 | XSETFASTINT (w->min_hscroll, 0); | 3292 | XSETFASTINT (w->min_hscroll, 0); |
| 3298 | XSETFASTINT (w->use_time, 0); | 3293 | XSETFASTINT (w->use_time, 0); |
| 3299 | ++sequence_number; | 3294 | ++sequence_number; |
| 3300 | XSETFASTINT (w->sequence_number, sequence_number); | 3295 | XSETFASTINT (w->sequence_number, sequence_number); |
| 3301 | w->temslot = w->last_modified = w->last_overlay_modified = Qnil; | ||
| 3302 | XSETFASTINT (w->last_point, 0); | 3296 | XSETFASTINT (w->last_point, 0); |
| 3303 | w->last_had_star = 0; | ||
| 3304 | w->vertical_scroll_bar = Qnil; | ||
| 3305 | w->left_margin_cols = w->right_margin_cols = Qnil; | ||
| 3306 | w->left_fringe_width = w->right_fringe_width = Qnil; | ||
| 3307 | w->fringes_outside_margins = Qnil; | ||
| 3308 | w->scroll_bar_width = Qnil; | ||
| 3309 | w->vertical_scroll_bar_type = Qt; | 3297 | w->vertical_scroll_bar_type = Qt; |
| 3310 | XSETFASTINT (w->window_end_pos, 0); | 3298 | XSETFASTINT (w->window_end_pos, 0); |
| 3311 | XSETFASTINT (w->window_end_vpos, 0); | 3299 | XSETFASTINT (w->window_end_vpos, 0); |
| 3312 | w->window_end_valid = w->display_table = Qnil; | 3300 | |
| 3313 | w->update_mode_line = w->start_at_line_beg = 0; | 3301 | /* Initialize non-Lisp data. Note that allocate_window zeroes out all |
| 3314 | w->dedicated = Qnil; | 3302 | non-Lisp data, so do it only for slots which should not be zero. */ |
| 3315 | w->base_line_number = w->base_line_pos = w->region_showing = Qnil; | ||
| 3316 | w->column_number_displayed = w->redisplay_end_trigger = Qnil; | ||
| 3317 | w->combination_limit = w->window_parameters = Qnil; | ||
| 3318 | w->prev_buffers = w->next_buffers = Qnil; | ||
| 3319 | /* Initialize non-Lisp data. */ | ||
| 3320 | w->desired_matrix = w->current_matrix = 0; | ||
| 3321 | w->nrows_scale_factor = w->ncols_scale_factor = 1; | 3303 | w->nrows_scale_factor = w->ncols_scale_factor = 1; |
| 3322 | memset (&w->cursor, 0, sizeof (w->cursor)); | ||
| 3323 | memset (&w->last_cursor, 0, sizeof (w->last_cursor)); | ||
| 3324 | memset (&w->phys_cursor, 0, sizeof (w->phys_cursor)); | ||
| 3325 | w->phys_cursor_type = -1; | 3304 | w->phys_cursor_type = -1; |
| 3326 | w->phys_cursor_width = -1; | 3305 | w->phys_cursor_width = -1; |
| 3327 | w->phys_cursor_on_p = 0; | 3306 | |
| 3328 | w->last_cursor_off_p = w->cursor_off_p = 0; | ||
| 3329 | w->must_be_updated_p = 0; | ||
| 3330 | w->pseudo_window_p = 0; | ||
| 3331 | w->frozen_window_start_p = 0; | ||
| 3332 | w->vscroll = 0; | ||
| 3333 | /* Reset window_list. */ | 3307 | /* Reset window_list. */ |
| 3334 | Vwindow_list = Qnil; | 3308 | Vwindow_list = Qnil; |
| 3335 | /* Return window. */ | 3309 | /* Return window. */ |