diff options
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 45 |
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 |
| 210 | struct suspicious_free_record { | 210 | struct 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 | }; |
| 216 | static void* suspicious_objects[32]; | 216 | static void *suspicious_objects[32]; |
| 217 | static int suspicious_object_index; | 217 | static int suspicious_object_index; |
| 218 | struct suspicious_free_record suspicious_free_history[64]; | 218 | struct suspicious_free_record suspicious_free_history[64]; |
| 219 | static int suspicious_free_history_index; | 219 | static 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. */ |
| 222 | static void* find_suspicious_object_in_range (void* begin, void* end); | 222 | static void *find_suspicious_object_in_range (void *begin, void *end); |
| 223 | static void detect_suspicious_free (void* ptr); | 223 | static 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 | ||
| 6831 | static void* | 6830 | static void* |
| 6832 | find_suspicious_object_in_range (void* begin, void* end) | 6831 | find_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 | ||
| 6847 | static void | 6847 | static void |
| 6848 | detect_suspicious_free (void* ptr) | 6848 | detect_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 | } |