aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
authorDmitry Antipov2012-06-26 18:41:01 +0400
committerDmitry Antipov2012-06-26 18:41:01 +0400
commit62efea5e881407a178c5c291575facc17dca8a3f (patch)
tree03224f091836b782bea0e86c76d9135d9a5f86bf /src/alloc.c
parent995a55159dc4b4831e45fe9827a99cadad1bcbd3 (diff)
downloademacs-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/alloc.c')
-rw-r--r--src/alloc.c39
1 files changed, 24 insertions, 15 deletions
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
3282struct window * 3281struct window *
3283allocate_window (void) 3282allocate_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
3289struct terminal * 3293struct terminal *
3290allocate_terminal (void) 3294allocate_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
3301struct frame * 3305struct frame *
3302allocate_frame (void) 3306allocate_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
3313struct Lisp_Process * 3317struct Lisp_Process *
3314allocate_process (void) 3318allocate_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
3320DEFUN ("make-vector", Fmake_vector, Smake_vector, 2, 2, 0, 3329DEFUN ("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.