aboutsummaryrefslogtreecommitdiffstats
path: root/src/ralloc.c
diff options
context:
space:
mode:
authorJason Rumney2008-12-24 11:37:12 +0000
committerJason Rumney2008-12-24 11:37:12 +0000
commit747d9d142f491daeec55df386d626915ddb3b5dc (patch)
treec1f737572d2913c4256a4226d451ace30ada49b2 /src/ralloc.c
parentbaae5c2d8453b653cb1cffd638d9bd90064d6275 (diff)
downloademacs-747d9d142f491daeec55df386d626915ddb3b5dc.tar.gz
emacs-747d9d142f491daeec55df386d626915ddb3b5dc.zip
Add comments to explain checks and aborts, to assist future debugging.
Diffstat (limited to 'src/ralloc.c')
-rw-r--r--src/ralloc.c11
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)
402 402
403 while (p != NIL_BLOC) 403 while (p != NIL_BLOC)
404 { 404 {
405 /* Consistency check. Don't return inconsistent blocs.
406 Don't abort here, as callers might be expecting this, but
407 callers that always expect a bloc to be returned should abort
408 if one isn't to avoid a memory corruption bug that is
409 difficult to track down. */
405 if (p->variable == ptr && p->data == *ptr) 410 if (p->variable == ptr && p->data == *ptr)
406 return p; 411 return p;
407 412
@@ -981,7 +986,7 @@ r_alloc_free (ptr)
981 986
982 dead_bloc = find_bloc (ptr); 987 dead_bloc = find_bloc (ptr);
983 if (dead_bloc == NIL_BLOC) 988 if (dead_bloc == NIL_BLOC)
984 abort (); 989 abort (); /* Double free? PTR not originally used to allocate? */
985 990
986 free_bloc (dead_bloc); 991 free_bloc (dead_bloc);
987 *ptr = 0; 992 *ptr = 0;
@@ -1025,7 +1030,7 @@ r_re_alloc (ptr, size)
1025 1030
1026 bloc = find_bloc (ptr); 1031 bloc = find_bloc (ptr);
1027 if (bloc == NIL_BLOC) 1032 if (bloc == NIL_BLOC)
1028 abort (); 1033 abort (); /* Already freed? PTR not originally used to allocate? */
1029 1034
1030 if (size < bloc->size) 1035 if (size < bloc->size)
1031 { 1036 {
@@ -1246,7 +1251,7 @@ r_alloc_reset_variable (old, new)
1246 } 1251 }
1247 1252
1248 if (bloc == NIL_BLOC || bloc->variable != old) 1253 if (bloc == NIL_BLOC || bloc->variable != old)
1249 abort (); 1254 abort (); /* Already freed? OLD not originally used to allocate? */
1250 1255
1251 /* Update variable to point to the new location. */ 1256 /* Update variable to point to the new location. */
1252 bloc->variable = new; 1257 bloc->variable = new;