aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
authorPaul Eggert2014-04-05 12:30:36 -0700
committerPaul Eggert2014-04-05 12:30:36 -0700
commitfaa521749378dbfd97f49a0e5c48f6da2ce1ddba (patch)
treed470dbfa3328aaeffe5cba065103e237238a13be /src/alloc.c
parent1b058e42524353c9ff133ea330876ed2d39b6515 (diff)
downloademacs-faa521749378dbfd97f49a0e5c48f6da2ce1ddba.tar.gz
emacs-faa521749378dbfd97f49a0e5c48f6da2ce1ddba.zip
Prefer 'ARRAYELTS (x)' to 'sizeof x / sizeof *x'.
* alloc.c (memory_full): * charset.c (syms_of_charset): * doc.c (Fsnarf_documentation): * emacs.c (main): * font.c (BUILD_STYLE_TABLE): * keyboard.c (make_lispy_event): * profiler.c (setup_cpu_timer): * xgselect.c (xg_select): * xterm.c (record_event, STORE_KEYSYM_FOR_DEBUG): Use ARRAYELTS. * font.c (FONT_PROPERTY_TABLE_SIZE): Remove. Replace the only use with ARRAYELTS (font_property_table). * xfaces.c (DIM): Remove. All uses replaced by ARRAYELTS.
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c45
1 files changed, 23 insertions, 22 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 9740afe2ab8..2919c21dfe5 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -208,19 +208,19 @@ const char *pending_malloc_warning;
208 208
209#ifdef SUSPICIOUS_OBJECT_CHECKING 209#ifdef SUSPICIOUS_OBJECT_CHECKING
210struct suspicious_free_record { 210struct suspicious_free_record {
211 void* suspicious_object; 211 void *suspicious_object;
212#ifdef HAVE_EXECINFO_H 212#ifdef HAVE_EXECINFO_H
213 void* backtrace[128]; 213 void *backtrace[128];
214#endif 214#endif
215}; 215};
216static void* suspicious_objects[32]; 216static void *suspicious_objects[32];
217static int suspicious_object_index; 217static int suspicious_object_index;
218struct suspicious_free_record suspicious_free_history[64]; 218struct suspicious_free_record suspicious_free_history[64];
219static int suspicious_free_history_index; 219static int suspicious_free_history_index;
220/* Find the first currently-monitored suspicious pointer in range 220/* Find the first currently-monitored suspicious pointer in range
221 [begin,end) or NULL if no such pointer exists. */ 221 [begin,end) or NULL if no such pointer exists. */
222static void* find_suspicious_object_in_range (void* begin, void* end); 222static void *find_suspicious_object_in_range (void *begin, void *end);
223static void detect_suspicious_free (void* ptr); 223static void detect_suspicious_free (void *ptr);
224#else 224#else
225#define find_suspicious_object_in_range(begin, end) NULL 225#define find_suspicious_object_in_range(begin, end) NULL
226#define detect_suspicious_free(ptr) (void) 226#define detect_suspicious_free(ptr) (void)
@@ -3116,7 +3116,7 @@ allocate_vectorlike (ptrdiff_t len)
3116 mallopt (M_MMAP_MAX, MMAP_MAX_AREAS); 3116 mallopt (M_MMAP_MAX, MMAP_MAX_AREAS);
3117#endif 3117#endif
3118 3118
3119 if (find_suspicious_object_in_range (p, (char*)p + nbytes)) 3119 if (find_suspicious_object_in_range (p, (char *) p + nbytes))
3120 emacs_abort (); 3120 emacs_abort ();
3121 3121
3122 consing_since_gc += nbytes; 3122 consing_since_gc += nbytes;
@@ -3765,7 +3765,7 @@ memory_full (size_t nbytes)
3765 memory_full_cons_threshold = sizeof (struct cons_block); 3765 memory_full_cons_threshold = sizeof (struct cons_block);
3766 3766
3767 /* The first time we get here, free the spare memory. */ 3767 /* The first time we get here, free the spare memory. */
3768 for (i = 0; i < sizeof (spare_memory) / sizeof (char *); i++) 3768 for (i = 0; i < ARRAYELTS (spare_memory); i++)
3769 if (spare_memory[i]) 3769 if (spare_memory[i])
3770 { 3770 {
3771 if (i == 0) 3771 if (i == 0)
@@ -3818,7 +3818,6 @@ refill_memory_reserve (void)
3818 Vmemory_full = Qnil; 3818 Vmemory_full = Qnil;
3819#endif 3819#endif
3820} 3820}
3821
3822 3821
3823/************************************************************************ 3822/************************************************************************
3824 C Stack Marking 3823 C Stack Marking
@@ -6829,23 +6828,24 @@ which_symbols (Lisp_Object obj, EMACS_INT find_max)
6829#ifdef SUSPICIOUS_OBJECT_CHECKING 6828#ifdef SUSPICIOUS_OBJECT_CHECKING
6830 6829
6831static void* 6830static void*
6832find_suspicious_object_in_range (void* begin, void* end) 6831find_suspicious_object_in_range (void *begin, void *end)
6833{ 6832{
6834 char* begin_a = begin; 6833 char *begin_a = begin;
6835 char* end_a = end; 6834 char *end_a = end;
6836 int i; 6835 int i;
6837 6836
6838 for (i = 0; i < ARRAYELTS (suspicious_objects); ++i) { 6837 for (i = 0; i < ARRAYELTS (suspicious_objects); ++i)
6839 char* suspicious_object = suspicious_objects[i]; 6838 {
6840 if (begin_a <= suspicious_object && suspicious_object < end_a) 6839 char *suspicious_object = suspicious_objects[i];
6841 return suspicious_object; 6840 if (begin_a <= suspicious_object && suspicious_object < end_a)
6842 } 6841 return suspicious_object;
6842 }
6843 6843
6844 return NULL; 6844 return NULL;
6845} 6845}
6846 6846
6847static void 6847static void
6848detect_suspicious_free (void* ptr) 6848detect_suspicious_free (void *ptr)
6849{ 6849{
6850 int i; 6850 int i;
6851 struct suspicious_free_record* rec; 6851 struct suspicious_free_record* rec;
@@ -6882,11 +6882,12 @@ garbage collection bugs. Otherwise, do nothing and return OBJ. */)
6882{ 6882{
6883#ifdef SUSPICIOUS_OBJECT_CHECKING 6883#ifdef SUSPICIOUS_OBJECT_CHECKING
6884 /* Right now, we care only about vectors. */ 6884 /* Right now, we care only about vectors. */
6885 if (VECTORLIKEP (obj)) { 6885 if (VECTORLIKEP (obj))
6886 suspicious_objects[suspicious_object_index++] = XVECTOR (obj); 6886 {
6887 if (suspicious_object_index == ARRAYELTS (suspicious_objects)) 6887 suspicious_objects[suspicious_object_index++] = XVECTOR (obj);
6888 suspicious_object_index = 0; 6888 if (suspicious_object_index == ARRAYELTS (suspicious_objects))
6889 } 6889 suspicious_object_index = 0;
6890 }
6890#endif 6891#endif
6891 return obj; 6892 return obj;
6892} 6893}