Mercurial > emacs
comparison src/alloc.c @ 84954:e4706ef9521d
(allocate_terminal): Set the vector size to only count the Lisp fields.
Initialize those to nil.
(mark_object): Don't treat terminals specially.
(mark_terminal): Remove.
(mark_terminals): Use mark_object instead.
| author | Stefan Monnier <monnier@iro.umontreal.ca> |
|---|---|
| date | Thu, 27 Sep 2007 19:51:39 +0000 |
| parents | 4d1c866492b0 |
| children | 3747382d60e9 |
comparison
equal
deleted
inserted
replaced
| 84953:0440e26f0af7 | 84954:e4706ef9521d |
|---|---|
| 3021 | 3021 |
| 3022 | 3022 |
| 3023 struct terminal * | 3023 struct terminal * |
| 3024 allocate_terminal () | 3024 allocate_terminal () |
| 3025 { | 3025 { |
| 3026 EMACS_INT len = VECSIZE (struct terminal); | 3026 /* Memory-footprint of the object in nb of Lisp_Object fields. */ |
| 3027 struct Lisp_Vector *v = allocate_vectorlike (len, MEM_TYPE_TERMINAL); | 3027 EMACS_INT memlen = VECSIZE (struct terminal); |
| 3028 /* Size if we only count the actual Lisp_Object fields (which need to be | |
| 3029 traced by the GC). */ | |
| 3030 EMACS_INT lisplen = PSEUDOVECSIZE (struct terminal, next_terminal); | |
| 3031 struct Lisp_Vector *v = allocate_vectorlike (memlen, MEM_TYPE_TERMINAL); | |
| 3028 EMACS_INT i; | 3032 EMACS_INT i; |
| 3029 Lisp_Object tmp, zero = make_number (0); | 3033 Lisp_Object tmp, zero = make_number (0); |
| 3030 | 3034 |
| 3031 for (i = 0; i < len; ++i) | 3035 for (i = 0; i < lisplen; ++i) |
| 3036 v->contents[i] = Qnil; | |
| 3037 for (;i < memlen; ++i) | |
| 3032 v->contents[i] = zero; | 3038 v->contents[i] = zero; |
| 3033 v->size = len; | 3039 v->size = lisplen; /* Only trace the Lisp fields. */ |
| 3034 XSETTERMINAL (tmp, v); /* Add the appropriate tag. */ | 3040 XSETTERMINAL (tmp, v); /* Add the appropriate tag. */ |
| 3035 | 3041 |
| 3036 return (struct terminal *) v; | 3042 return (struct terminal *) v; |
| 3037 } | 3043 } |
| 3038 | 3044 |
| 5681 { | 5687 { |
| 5682 mark_glyph_matrix (w->current_matrix); | 5688 mark_glyph_matrix (w->current_matrix); |
| 5683 mark_glyph_matrix (w->desired_matrix); | 5689 mark_glyph_matrix (w->desired_matrix); |
| 5684 } | 5690 } |
| 5685 } | 5691 } |
| 5686 else if (GC_TERMINALP (obj)) | |
| 5687 { | |
| 5688 CHECK_LIVE (live_vector_p); | |
| 5689 mark_terminal (XTERMINAL (obj)); | |
| 5690 } | |
| 5691 else if (GC_HASH_TABLE_P (obj)) | 5692 else if (GC_HASH_TABLE_P (obj)) |
| 5692 { | 5693 { |
| 5693 struct Lisp_Hash_Table *h = XHASH_TABLE (obj); | 5694 struct Lisp_Hash_Table *h = XHASH_TABLE (obj); |
| 5694 | 5695 |
| 5695 /* Stop if already marked. */ | 5696 /* Stop if already marked. */ |
| 5933 | 5934 |
| 5934 /* Mark the Lisp pointers in the terminal objects. | 5935 /* Mark the Lisp pointers in the terminal objects. |
| 5935 Called by the Fgarbage_collector. */ | 5936 Called by the Fgarbage_collector. */ |
| 5936 | 5937 |
| 5937 static void | 5938 static void |
| 5938 mark_terminal (struct terminal *t) | |
| 5939 { | |
| 5940 VECTOR_MARK (t); | |
| 5941 mark_object (t->param_alist); | |
| 5942 } | |
| 5943 | |
| 5944 static void | |
| 5945 mark_terminals (void) | 5939 mark_terminals (void) |
| 5946 { | 5940 { |
| 5947 struct terminal *t; | 5941 struct terminal *t; |
| 5942 Lisp_Object tmp; | |
| 5948 for (t = terminal_list; t; t = t->next_terminal) | 5943 for (t = terminal_list; t; t = t->next_terminal) |
| 5949 { | 5944 { |
| 5950 eassert (t->name != NULL); | 5945 eassert (t->name != NULL); |
| 5951 mark_terminal (t); | 5946 XSETVECTOR (tmp, t); |
| 5947 mark_object (tmp); | |
| 5952 } | 5948 } |
| 5953 } | 5949 } |
| 5954 | 5950 |
| 5955 | 5951 |
| 5956 | 5952 |
