summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ChangeLog6
-rw-r--r--src/alloc.c34
2 files changed, 26 insertions, 14 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index a628148bbda..b2a8f81f3a6 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,11 @@
2014-04-03 Daniel Colascione <dancol@dancol.org>
+ * alloc.c (detect_suspicious_free): Split actual stack capturing
+ out into new function for easier breakpoint setting.
+ (note_suspicious_free): New function.
+
+2014-04-03 Daniel Colascione <dancol@dancol.org>
+
In all places below, change expressions of the form sizeof(arr) /
sizeof(arr[0]) to EARRAYSIZE(arr).
diff --git a/src/alloc.c b/src/alloc.c
index 46b4f5021df..7c63fa05ac6 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -6845,28 +6845,34 @@ find_suspicious_object_in_range (void* begin, void* end)
}
static void
-detect_suspicious_free (void* ptr)
+note_suspicious_free (void* ptr)
{
- int i;
struct suspicious_free_record* rec;
+ rec = &suspicious_free_history[suspicious_free_history_index++];
+ if (suspicious_free_history_index ==
+ EARRAYSIZE (suspicious_free_history))
+ {
+ suspicious_free_history_index = 0;
+ }
+
+ memset (rec, 0, sizeof (*rec));
+ rec->suspicious_object = ptr;
+#ifdef HAVE_EXECINFO_H
+ backtrace (&rec->backtrace[0], EARRAYSIZE (rec->backtrace));
+#endif
+}
+
+static void
+detect_suspicious_free (void* ptr)
+{
+ int i;
eassert (ptr != NULL);
for (i = 0; i < EARRAYSIZE (suspicious_objects); ++i)
if (suspicious_objects[i] == ptr)
{
- rec = &suspicious_free_history[suspicious_free_history_index++];
- if (suspicious_free_history_index ==
- EARRAYSIZE (suspicious_free_history))
- {
- suspicious_free_history_index = 0;
- }
-
- memset (rec, 0, sizeof (*rec));
- rec->suspicious_object = ptr;
-#ifdef HAVE_EXECINFO_H
- backtrace (&rec->backtrace[0], EARRAYSIZE (rec->backtrace));
-#endif
+ note_suspicious_free (ptr);
suspicious_objects[i] = NULL;
}
}