diff options
| author | Paul Eggert | 2012-04-15 20:38:40 -0700 |
|---|---|---|
| committer | Paul Eggert | 2012-04-15 20:38:40 -0700 |
| commit | b62a57beb523298caa95c2d85c65eeb6e9af7af9 (patch) | |
| tree | 26f5a8bdf3c68bced1be3eb2e09807e9123cd3bb /src/alloc.c | |
| parent | 3539f31f03b40bafa0875de88e3a5d55558ba32c (diff) | |
| download | emacs-b62a57beb523298caa95c2d85c65eeb6e9af7af9.tar.gz emacs-b62a57beb523298caa95c2d85c65eeb6e9af7af9.zip | |
Fix minor alloc.c problems found by static checking.
* alloc.c (_malloc_internal, _free_internal) [!DOUG_LEA_MALLOC]:
New extern decls, to avoid calling undeclared functions.
(dont_register_blocks): Define if ((!SYSTEM_MALLOC && !SYNC_INPUT)
&& GC_MALLOC_CHECK), not if ((GC_MARK_STACK || defined
GC_MALLOC_CHECK) && GC_MALLOC_CHECK), to match when it's used.
(NEED_MEM_INSERT): New macro.
(mem_insert, mem_insert_fixup) [!NEED_MEM_INSERT]: Remove; unused.
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/alloc.c b/src/alloc.c index 0e68817629c..9589ae05e95 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -82,6 +82,8 @@ extern POINTER_TYPE *sbrk (); | |||
| 82 | 82 | ||
| 83 | extern size_t _bytes_used; | 83 | extern size_t _bytes_used; |
| 84 | extern size_t __malloc_extra_blocks; | 84 | extern size_t __malloc_extra_blocks; |
| 85 | extern void *_malloc_internal (size_t); | ||
| 86 | extern void _free_internal (void *); | ||
| 85 | 87 | ||
| 86 | #endif /* not DOUG_LEA_MALLOC */ | 88 | #endif /* not DOUG_LEA_MALLOC */ |
| 87 | 89 | ||
| @@ -314,7 +316,6 @@ static Lisp_Object Vdead; | |||
| 314 | #ifdef GC_MALLOC_CHECK | 316 | #ifdef GC_MALLOC_CHECK |
| 315 | 317 | ||
| 316 | enum mem_type allocated_mem_type; | 318 | enum mem_type allocated_mem_type; |
| 317 | static int dont_register_blocks; | ||
| 318 | 319 | ||
| 319 | #endif /* GC_MALLOC_CHECK */ | 320 | #endif /* GC_MALLOC_CHECK */ |
| 320 | 321 | ||
| @@ -391,8 +392,13 @@ static int live_misc_p (struct mem_node *, void *); | |||
| 391 | static void mark_maybe_object (Lisp_Object); | 392 | static void mark_maybe_object (Lisp_Object); |
| 392 | static void mark_memory (void *, void *); | 393 | static void mark_memory (void *, void *); |
| 393 | static void mem_init (void); | 394 | static void mem_init (void); |
| 395 | #if (defined GC_MALLOC_CHECK \ | ||
| 396 | ? !defined SYSTEM_MALLOC && !defined SYNC_INPUT \ | ||
| 397 | : GC_MARK_STACK) | ||
| 398 | # define NEED_MEM_INSERT | ||
| 394 | static struct mem_node *mem_insert (void *, void *, enum mem_type); | 399 | static struct mem_node *mem_insert (void *, void *, enum mem_type); |
| 395 | static void mem_insert_fixup (struct mem_node *); | 400 | static void mem_insert_fixup (struct mem_node *); |
| 401 | #endif | ||
| 396 | static void mem_rotate_left (struct mem_node *); | 402 | static void mem_rotate_left (struct mem_node *); |
| 397 | static void mem_rotate_right (struct mem_node *); | 403 | static void mem_rotate_right (struct mem_node *); |
| 398 | static void mem_delete (struct mem_node *); | 404 | static void mem_delete (struct mem_node *); |
| @@ -1223,6 +1229,10 @@ static void (*old_free_hook) (void*, const void*); | |||
| 1223 | # define BYTES_USED _bytes_used | 1229 | # define BYTES_USED _bytes_used |
| 1224 | #endif | 1230 | #endif |
| 1225 | 1231 | ||
| 1232 | #ifdef GC_MALLOC_CHECK | ||
| 1233 | static int dont_register_blocks; | ||
| 1234 | #endif | ||
| 1235 | |||
| 1226 | static size_t bytes_used_when_reconsidered; | 1236 | static size_t bytes_used_when_reconsidered; |
| 1227 | 1237 | ||
| 1228 | /* Value of _bytes_used, when spare_memory was freed. */ | 1238 | /* Value of _bytes_used, when spare_memory was freed. */ |
| @@ -3571,6 +3581,8 @@ mem_find (void *start) | |||
| 3571 | } | 3581 | } |
| 3572 | 3582 | ||
| 3573 | 3583 | ||
| 3584 | #ifdef NEED_MEM_INSERT | ||
| 3585 | |||
| 3574 | /* Insert a new node into the tree for a block of memory with start | 3586 | /* Insert a new node into the tree for a block of memory with start |
| 3575 | address START, end address END, and type TYPE. Value is a | 3587 | address START, end address END, and type TYPE. Value is a |
| 3576 | pointer to the node that was inserted. */ | 3588 | pointer to the node that was inserted. */ |
| @@ -3718,6 +3730,8 @@ mem_insert_fixup (struct mem_node *x) | |||
| 3718 | mem_root->color = MEM_BLACK; | 3730 | mem_root->color = MEM_BLACK; |
| 3719 | } | 3731 | } |
| 3720 | 3732 | ||
| 3733 | #endif /* NEED_MEM_INSERT */ | ||
| 3734 | |||
| 3721 | 3735 | ||
| 3722 | /* (x) (y) | 3736 | /* (x) (y) |
| 3723 | / \ / \ | 3737 | / \ / \ |