diff options
| author | Jason Rumney <jasonr@gnu.org> | 2008-12-24 11:37:12 +0000 |
|---|---|---|
| committer | Jason Rumney <jasonr@gnu.org> | 2008-12-24 11:37:12 +0000 |
| commit | 747d9d142f491daeec55df386d626915ddb3b5dc (patch) | |
| tree | c1f737572d2913c4256a4226d451ace30ada49b2 /src/ralloc.c | |
| parent | baae5c2d8453b653cb1cffd638d9bd90064d6275 (diff) | |
| download | emacs-747d9d142f491daeec55df386d626915ddb3b5dc.tar.gz | |
Add comments to explain checks and aborts, to assist future debugging.
Diffstat (limited to 'src/ralloc.c')
| -rw-r--r-- | src/ralloc.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/ralloc.c b/src/ralloc.c index 61f7aff95f5..a484cb60cfc 100644 --- a/src/ralloc.c +++ b/src/ralloc.c @@ -402,6 +402,11 @@ find_bloc (ptr) while (p != NIL_BLOC) { + /* Consistency check. Don't return inconsistent blocs. + Don't abort here, as callers might be expecting this, but + callers that always expect a bloc to be returned should abort + if one isn't to avoid a memory corruption bug that is + difficult to track down. */ if (p->variable == ptr && p->data == *ptr) return p; @@ -981,7 +986,7 @@ r_alloc_free (ptr) dead_bloc = find_bloc (ptr); if (dead_bloc == NIL_BLOC) - abort (); + abort (); /* Double free? PTR not originally used to allocate? */ free_bloc (dead_bloc); *ptr = 0; @@ -1025,7 +1030,7 @@ r_re_alloc (ptr, size) bloc = find_bloc (ptr); if (bloc == NIL_BLOC) - abort (); + abort (); /* Already freed? PTR not originally used to allocate? */ if (size < bloc->size) { @@ -1246,7 +1251,7 @@ r_alloc_reset_variable (old, new) } if (bloc == NIL_BLOC || bloc->variable != old) - abort (); + abort (); /* Already freed? OLD not originally used to allocate? */ /* Update variable to point to the new location. */ bloc->variable = new; |
