summaryrefslogtreecommitdiff
path: root/tal-debug.c
diff options
context:
space:
mode:
authorKevin Ryde <user42@zip.com.au>2001-11-19 22:13:42 +0100
committerKevin Ryde <user42@zip.com.au>2001-11-19 22:13:42 +0100
commit9061b62c3a43ce5fd7e5d0f0b7dfeb223fcbebed (patch)
tree036977250eb8246de5cae39b58b4fc7a5051b92b /tal-debug.c
parent4f579b097d6eb8ff649f780105347d9045ea7231 (diff)
downloadgmp-9061b62c3a43ce5fd7e5d0f0b7dfeb223fcbebed.tar.gz
* tal-debug.c, gmp-impl.h: More checks of TMP_DECL/TMP_MARK/TMP_FREE
consistency.
Diffstat (limited to 'tal-debug.c')
-rw-r--r--tal-debug.c37
1 files changed, 29 insertions, 8 deletions
diff --git a/tal-debug.c b/tal-debug.c
index 3606cf574..59453cd45 100644
--- a/tal-debug.c
+++ b/tal-debug.c
@@ -49,12 +49,21 @@ MA 02111-1307, USA. */
void
__gmp_tmp_debug_mark (const char *file, int line,
- struct tmp_debug_t **markp, struct tmp_debug_t *mark)
+ struct tmp_debug_t **markp, struct tmp_debug_t *mark,
+ const char *decl_name, const char *mark_name)
{
+ if (strcmp (mark_name, decl_name) != 0)
+ {
+ __gmp_assert_header (file, line);
+ fprintf (stderr, "GNU MP: TMP_MARK(%s) but TMP_DECL(%s) is in scope\n",
+ mark_name, decl_name);
+ abort ();
+ }
+
if (*markp != NULL)
{
__gmp_assert_header (file, line);
- fprintf (stderr, "GNU MP: Duplicate TMP_MARK\n");
+ fprintf (stderr, "GNU MP: Repeat of TMP_MARK(%s)\n", mark_name);
if (mark->file != NULL && mark->file[0] != '\0' && mark->line != -1)
{
__gmp_assert_header (mark->file, mark->line);
@@ -68,10 +77,11 @@ __gmp_tmp_debug_mark (const char *file, int line,
mark->line = line;
mark->list = NULL;
}
-
+
void *
-__gmp_tmp_debug_alloc (const char *file, int line,
- struct tmp_debug_t **markp, size_t size)
+__gmp_tmp_debug_alloc (const char *file, int line, int dummy,
+ struct tmp_debug_t **markp,
+ const char *decl_name, size_t size)
{
struct tmp_debug_t *mark = *markp;
struct tmp_debug_entry_t *p;
@@ -81,7 +91,7 @@ __gmp_tmp_debug_alloc (const char *file, int line,
if (mark == NULL)
{
__gmp_assert_header (file, line);
- fprintf (stderr, "GNU MP: TMP_ALLOC without TMP_MARK\n");
+ fprintf (stderr, "GNU MP: TMP_ALLOC without TMP_MARK(%s)\n", decl_name);
abort ();
}
@@ -94,7 +104,9 @@ __gmp_tmp_debug_alloc (const char *file, int line,
}
void
-__gmp_tmp_debug_free (const char *file, int line, struct tmp_debug_t **markp)
+__gmp_tmp_debug_free (const char *file, int line, int dummy,
+ struct tmp_debug_t **markp,
+ const char *decl_name, const char *free_name)
{
struct tmp_debug_t *mark = *markp;
struct tmp_debug_entry_t *p, *next;
@@ -102,7 +114,16 @@ __gmp_tmp_debug_free (const char *file, int line, struct tmp_debug_t **markp)
if (mark == NULL)
{
__gmp_assert_header (file, line);
- fprintf (stderr, "GNU MP: TMP_FREE without TMP_MARK\n");
+ fprintf (stderr, "GNU MP: TMP_FREE(%s) without TMP_MARK(%s)\n",
+ free_name, decl_name);
+ abort ();
+ }
+
+ if (strcmp (free_name, decl_name) != 0)
+ {
+ __gmp_assert_header (file, line);
+ fprintf (stderr, "GNU MP: TMP_FREE(%s) when TMP_DECL(%s) is in scope\n",
+ free_name, decl_name);
abort ();
}