Blob Blame Raw
Description: <short summary of the patch>
 TODO: Put a short summary on the line above and replace this paragraph
 with a longer explanation of this change. Complete the meta-information
 with other relevant fields (see below for details). To make it easier, the
 information below has been extracted from the changelog. Adjust it or drop
 it.
 .
 gcl (2.6.12-2) unstable; urgency=medium
 .
   * Version_2_6_13pre1
Author: Camm Maguire <camm@debian.org>

---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: <YYYY-MM-DD>

--- gcl-2.6.12.orig/o/alloc.c
+++ gcl-2.6.12/o/alloc.c
@@ -1269,10 +1269,11 @@ gcl_init_alloc(void *cs_start) {
   update_real_maxpage();
 
   if (gcl_alloc_initialized) {
-    massert(rb_start==heap_end &&rb_end==heap_end && rb_limit==heap_end && rb_pointer==heap_end);
-    holepage=new_holepage;
-    alloc_page(-holepage);
-    rb_start=rb_end=rb_limit=rb_pointer=heap_end+(holepage<<PAGEWIDTH);
+    if (rb_start==heap_end && rb_end==rb_start && rb_limit==rb_start && rb_pointer==rb_start) {
+      holepage=new_holepage;
+      alloc_page(-holepage);
+      rb_start=rb_end=rb_limit=rb_pointer=heap_end+(holepage<<PAGEWIDTH);
+    }
     return;
   }
   
@@ -1814,25 +1815,19 @@ void
 free(void *ptr) {
 
   object *p,pp;
+  static void *initial_monstartup_pointer_echo;
   
   if (ptr == 0)
     return;
   
   for (p = &malloc_list,pp=*p; pp && !endp(pp);  p = &((pp)->c.c_cdr),pp=pp->c.c_cdr)
     if ((pp)->c.c_car->st.st_self == ptr) {
-      /* SGC contblock pages: Its possible this is on an old page CM 20030827 */
-/* #ifdef SGC */
-/*       insert_maybe_sgc_contblock((pp)->c.c_car->st.st_self,(pp)->c.c_car->st.st_dim); */
-/* #else */
-/*       insert_contblock((pp)->c.c_car->st.st_self,(pp)->c.c_car->st.st_dim); */
-/* #endif */
       (pp)->c.c_car->st.st_self = NULL;
       *p = pp->c.c_cdr;
 #ifdef GCL_GPROF
       if (initial_monstartup_pointer==ptr) {
+	initial_monstartup_pointer_echo=ptr;
 	initial_monstartup_pointer=NULL;
-	if (core_end-heap_end>=sizeof(ptr))
-	  *(void **)heap_end=ptr;
       }
 #endif
       return;
@@ -1840,12 +1835,13 @@ free(void *ptr) {
 #ifdef NOFREE_ERR
   return;
 #else	
-  if (core_end-heap_end<sizeof(ptr) || ptr!=*(void **)heap_end) {
+  if (ptr!=initial_monstartup_pointer_echo) {
     static void *old_ptr;
     if (old_ptr==ptr) return;
     old_ptr=ptr;
     FEerror("free(3) error.",0);
   }
+  initial_monstartup_pointer_echo=NULL;
   return;
 #endif	
 }