From: Paul Eggert Date: Mon, 16 Apr 2012 03:38:40 +0000 (-0700) Subject: Fix minor alloc.c problems found by static checking. X-Git-Tag: emacs-24.2.90~471^2~355^2 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=b62a57beb523298caa95c2d85c65eeb6e9af7af9;p=emacs.git 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. --- diff --git a/src/ChangeLog b/src/ChangeLog index 06ae5016cf3..7172ba605f5 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,14 @@ 2012-04-16 Paul Eggert + 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. + Fix minor ralloc.c problems found by static checking. See http://lists.gnu.org/archive/html/emacs-devel/2011-12/msg00720.html * ralloc.c (ALIGNED, ROUND_TO_PAGE, HEAP_PTR_SIZE) 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 (); extern size_t _bytes_used; extern size_t __malloc_extra_blocks; +extern void *_malloc_internal (size_t); +extern void _free_internal (void *); #endif /* not DOUG_LEA_MALLOC */ @@ -314,7 +316,6 @@ static Lisp_Object Vdead; #ifdef GC_MALLOC_CHECK enum mem_type allocated_mem_type; -static int dont_register_blocks; #endif /* GC_MALLOC_CHECK */ @@ -391,8 +392,13 @@ static int live_misc_p (struct mem_node *, void *); static void mark_maybe_object (Lisp_Object); static void mark_memory (void *, void *); static void mem_init (void); +#if (defined GC_MALLOC_CHECK \ + ? !defined SYSTEM_MALLOC && !defined SYNC_INPUT \ + : GC_MARK_STACK) +# define NEED_MEM_INSERT static struct mem_node *mem_insert (void *, void *, enum mem_type); static void mem_insert_fixup (struct mem_node *); +#endif static void mem_rotate_left (struct mem_node *); static void mem_rotate_right (struct mem_node *); static void mem_delete (struct mem_node *); @@ -1223,6 +1229,10 @@ static void (*old_free_hook) (void*, const void*); # define BYTES_USED _bytes_used #endif +#ifdef GC_MALLOC_CHECK +static int dont_register_blocks; +#endif + static size_t bytes_used_when_reconsidered; /* Value of _bytes_used, when spare_memory was freed. */ @@ -3571,6 +3581,8 @@ mem_find (void *start) } +#ifdef NEED_MEM_INSERT + /* Insert a new node into the tree for a block of memory with start address START, end address END, and type TYPE. Value is a pointer to the node that was inserted. */ @@ -3718,6 +3730,8 @@ mem_insert_fixup (struct mem_node *x) mem_root->color = MEM_BLACK; } +#endif /* NEED_MEM_INSERT */ + /* (x) (y) / \ / \