]> git.eshelyaron.com Git - emacs.git/commitdiff
* alloc.c: Simplify by removing use of HAVE_EXECINFO_H.
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 7 Apr 2014 17:52:38 +0000 (10:52 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 7 Apr 2014 17:52:38 +0000 (10:52 -0700)
We have a substitute execinfo.h on hosts that lack it.
(suspicious_free_history): Make it EXTERNALLY_VISIBLE so it
isn't optimized away.

src/ChangeLog
src/alloc.c

index de97b99073565ddccc0a695513b351b58f32b4bd..b4722839fe314f12c2ed6cc7778949ead57eff76 100644 (file)
@@ -1,3 +1,10 @@
+2014-04-07  Paul Eggert  <eggert@cs.ucla.edu>
+
+       * alloc.c: Simplify by removing use of HAVE_EXECINFO_H.
+       We have a substitute execinfo.h on hosts that lack it.
+       (suspicious_free_history): Make it EXTERNALLY_VISIBLE so it
+       isn't optimized away.
+
 2014-04-05  Paul Eggert  <eggert@cs.ucla.edu>
 
        Prefer 'ARRAYELTS (x)' to 'sizeof x / sizeof *x'.
index 2919c21dfe586e69d56619b18d736e3e45d26544..dbd1ece5d49434c9d636162f0b303245fae359f2 100644 (file)
@@ -47,10 +47,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #endif /* HAVE_WINDOW_SYSTEM */
 
 #include <verify.h>
-
-#ifdef HAVE_EXECINFO_H
-#include <execinfo.h>           /* For backtrace */
-#endif
+#include <execinfo.h>           /* For backtrace.  */
 
 #if (defined ENABLE_CHECKING                   \
      && defined HAVE_VALGRIND_VALGRIND_H       \
@@ -207,23 +204,22 @@ const char *pending_malloc_warning;
 #define SUSPICIOUS_OBJECT_CHECKING 1
 
 #ifdef SUSPICIOUS_OBJECT_CHECKING
-struct suspicious_free_record {
+struct suspicious_free_record
+{
   void *suspicious_object;
-#ifdef HAVE_EXECINFO_H
   void *backtrace[128];
-#endif
 };
 static void *suspicious_objects[32];
 static int suspicious_object_index;
-struct suspicious_free_record suspicious_free_history[64];
+struct suspicious_free_record suspicious_free_history[64] EXTERNALLY_VISIBLE;
 static int suspicious_free_history_index;
 /* Find the first currently-monitored suspicious pointer in range
    [begin,end) or NULL if no such pointer exists.  */
 static void *find_suspicious_object_in_range (void *begin, void *end);
 static void detect_suspicious_free (void *ptr);
 #else
-#define find_suspicious_object_in_range(begin, end) NULL
-#define detect_suspicious_free(ptr) (void)
+# define find_suspicious_object_in_range(begin, end) NULL
+# define detect_suspicious_free(ptr) (void)
 #endif
 
 /* Maximum amount of C stack to save when a GC happens.  */
@@ -6827,7 +6823,7 @@ which_symbols (Lisp_Object obj, EMACS_INT find_max)
 
 #ifdef SUSPICIOUS_OBJECT_CHECKING
 
-static void*
+static void *
 find_suspicious_object_in_range (void *begin, void *end)
 {
   char *begin_a = begin;
@@ -6848,14 +6844,14 @@ static void
 detect_suspicious_free (void *ptr)
 {
   int i;
-  struct suspicious_free_record* rec;
 
   eassert (ptr != NULL);
 
   for (i = 0; i < ARRAYELTS (suspicious_objects); ++i)
     if (suspicious_objects[i] == ptr)
       {
-        rec = &suspicious_free_history[suspicious_free_history_index++];
+       struct suspicious_free_record *rec
+         = &suspicious_free_history[suspicious_free_history_index++];
         if (suspicious_free_history_index ==
             ARRAYELTS (suspicious_free_history))
           {
@@ -6864,9 +6860,7 @@ detect_suspicious_free (void *ptr)
 
         memset (rec, 0, sizeof (*rec));
         rec->suspicious_object = ptr;
-#ifdef HAVE_EXECINFO_H
-        backtrace (&rec->backtrace[0], ARRAYELTS (rec->backtrace));
-#endif
+        backtrace (rec->backtrace, ARRAYELTS (rec->backtrace));
         suspicious_objects[i] = NULL;
       }
 }