[Gc] Minor fixes for GC_generic_malloc

Ivan Maidanski ivmai at mail.ru
Fri Oct 31 15:18:57 PST 2008


Hi!

This patch does:
- remove duplicate GC_init() call in GC_try_to_collect() ("alloc.c" file); and
- remove "lw" variable (thus suppressing "unused assigned value" warning for single-threaded case) in GC_generic_malloc[_ignore_off_page]() ("malloc.c" and "mallocx.c" files).

Bye.
-------------- next part --------------
diff -ru bdwgc/alloc.c updated/bdwgc/alloc.c
--- bdwgc/alloc.c	2008-10-28 22:34:16.000000000 +0300
+++ updated/bdwgc/alloc.c	2008-10-31 19:43:49.000000000 +0300
@@ -826,7 +826,6 @@
     GC_INVOKE_FINALIZERS();
     LOCK();
     ENTER_GC();
-    if (!GC_is_initialized) GC_init_inner();
     /* Minimize junk left in my registers */
       GC_noop(0,0,0,0,0,0);
     result = (int)GC_try_to_collect_inner(stop_func);
diff -ru bdwgc/malloc.c updated/bdwgc/malloc.c
--- bdwgc/malloc.c	2008-10-28 11:47:18.000000000 +0300
+++ updated/bdwgc/malloc.c	2008-10-31 22:43:38.000000000 +0300
@@ -159,12 +159,11 @@
         result = GC_generic_malloc_inner((word)lb, k);
 	UNLOCK();
     } else {
-	size_t lg, lw;
+	size_t lg;
 	size_t lb_rounded;
 	word n_blocks;
 	GC_bool init;
 	lg = ROUNDED_UP_GRANULES(lb);
-	lw = GRANULES_TO_WORDS(lg);
 	lb_rounded = GRANULES_TO_BYTES(lg);
 	n_blocks = OBJ_SZ_TO_BLOCKS(lb_rounded);
 	init = GC_obj_kinds[k].ok_init;
@@ -179,8 +178,8 @@
 	      /* before we release the lock.			      */
 	        ((word *)result)[0] = 0;
 	        ((word *)result)[1] = 0;
-	        ((word *)result)[lw-1] = 0;
-	        ((word *)result)[lw-2] = 0;
+	        ((word *)result)[GRANULES_TO_WORDS(lg)-1] = 0;
+	        ((word *)result)[GRANULES_TO_WORDS(lg)-2] = 0;
 #	    endif
 	  }
 	}
diff -ru bdwgc/mallocx.c updated/bdwgc/mallocx.c
--- bdwgc/mallocx.c	2008-10-28 17:57:41.000000000 +0300
+++ updated/bdwgc/mallocx.c	2008-10-31 22:44:58.000000000 +0300
@@ -167,7 +167,7 @@
 void * GC_generic_malloc_ignore_off_page(size_t lb, int k)
 {
     void *result;
-    size_t lg, lw;
+    size_t lg;
     size_t lb_rounded;
     word n_blocks;
     GC_bool init;
@@ -176,7 +176,6 @@
     if (SMALL_OBJ(lb))
         return(GC_generic_malloc((word)lb, k));
     lg = ROUNDED_UP_GRANULES(lb);
-    lw = GRANULES_TO_WORDS(lg);
     lb_rounded = GRANULES_TO_BYTES(lg);
     n_blocks = OBJ_SZ_TO_BLOCKS(lb_rounded);
     init = GC_obj_kinds[k].ok_init;
@@ -193,8 +192,8 @@
 	      /* before we release the lock.			      */
 	        ((word *)result)[0] = 0;
 	        ((word *)result)[1] = 0;
-	        ((word *)result)[lw-1] = 0;
-	        ((word *)result)[lw-2] = 0;
+	        ((word *)result)[GRANULES_TO_WORDS(lg)-1] = 0;
+	        ((word *)result)[GRANULES_TO_WORDS(lg)-2] = 0;
 #	    endif
         }
     }


More information about the Gc mailing list