]> granicus.if.org Git - gc/commitdiff
Remove redundant casts in GC_generic_or_special_malloc and similar
authorIvan Maidanski <ivmai@mail.ru>
Mon, 17 Feb 2014 20:50:14 +0000 (00:50 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Thu, 20 Feb 2014 21:15:08 +0000 (01:15 +0400)
(refactoring)

* mallocx.c (GC_generic_or_special_malloc,
GC_generic_malloc_ignore_off_page): Remove redundant casts for
"lb" argument; remove redundant parentheses.
* fnlz_mlc.c (GC_finalized_malloc): Likewise.
* malloc.c (GC_generic_malloc, GC_malloc_uncollectable): Likewise.
* malloc.c (GC_malloc_uncollectable): Remove redundant cast of
returned value.
* mallocx.c (GC_malloc_ignore_off_page,
GC_malloc_atomic_ignore_off_page): Likewise.

fnlz_mlc.c
malloc.c
mallocx.c

index 923810c8e035d56b3b44a4defddc87fe059da2e7..23735bdbb79d3e02563e2c53d5812da3ebbebc07 100644 (file)
@@ -98,7 +98,7 @@ GC_API void GC_CALL GC_register_disclaim_proc(int kind, GC_disclaim_proc proc,
         op = GC_finalized_objfreelist[lg];
         if (EXPECT(0 == op, FALSE)) {
             UNLOCK();
-            op = GC_generic_malloc((word)lb, GC_finalized_kind);
+            op = GC_generic_malloc(lb, GC_finalized_kind);
             if (NULL == op)
                 return NULL;
             /* GC_generic_malloc has extended the size map for us.      */
@@ -114,7 +114,7 @@ GC_API void GC_CALL GC_register_disclaim_proc(int kind, GC_disclaim_proc proc,
     } else {
         size_t op_sz;
 
-        op = GC_generic_malloc((word)lb, GC_finalized_kind);
+        op = GC_generic_malloc(lb, GC_finalized_kind);
         if (NULL == op)
             return NULL;
         op_sz = GC_size(op);
index 11bc8ce8a72aa762aa35ba3e8b2e035aad426270..836c916deaa70ec268362b81266f1f7325a71266 100644 (file)
--- a/malloc.c
+++ b/malloc.c
@@ -179,7 +179,7 @@ GC_API void * GC_CALL GC_generic_malloc(size_t lb, int k)
     GC_DBG_COLLECT_AT_MALLOC(lb);
     if (SMALL_OBJ(lb)) {
         LOCK();
-        result = GC_generic_malloc_inner((word)lb, k);
+        result = GC_generic_malloc_inner(lb, k);
         UNLOCK();
     } else {
         size_t lg;
@@ -312,15 +312,14 @@ GC_API void * GC_CALL GC_malloc_uncollectable(size_t lb)
             UNLOCK();
         } else {
             UNLOCK();
-            op = (ptr_t)GC_generic_malloc((word)lb, UNCOLLECTABLE);
+            op = GC_generic_malloc(lb, UNCOLLECTABLE);
             /* For small objects, the free lists are completely marked. */
         }
         GC_ASSERT(0 == op || GC_is_marked(op));
-        return((void *) op);
     } else {
         hdr * hhdr;
 
-        op = (ptr_t)GC_generic_malloc((word)lb, UNCOLLECTABLE);
+        op = GC_generic_malloc(lb, UNCOLLECTABLE);
         if (0 == op) return(0);
 
         GC_ASSERT(((word)op & (HBLKSIZE - 1)) == 0); /* large block */
@@ -337,8 +336,8 @@ GC_API void * GC_CALL GC_malloc_uncollectable(size_t lb)
 #       endif
         hhdr -> hb_n_marks = 1;
         UNLOCK();
-        return((void *) op);
     }
+    return op;
 }
 
 #ifdef REDIRECT_MALLOC
index a2d9c70e59970988b6b2a2f2d6f055211e715e07..de9fd931fadb669c71fe295dfcec3e278773e333 100644 (file)
--- a/mallocx.c
+++ b/mallocx.c
@@ -52,20 +52,20 @@ STATIC void * GC_generic_or_special_malloc(size_t lb, int knd)
     switch(knd) {
 #     ifdef STUBBORN_ALLOC
         case STUBBORN:
-            return(GC_malloc_stubborn((size_t)lb));
+            return GC_malloc_stubborn(lb);
 #     endif
         case PTRFREE:
-            return(GC_malloc_atomic((size_t)lb));
+            return GC_malloc_atomic(lb);
         case NORMAL:
-            return(GC_malloc((size_t)lb));
+            return GC_malloc(lb);
         case UNCOLLECTABLE:
-            return(GC_malloc_uncollectable((size_t)lb));
+            return GC_malloc_uncollectable(lb);
 #       ifdef ATOMIC_UNCOLLECTABLE
           case AUNCOLLECTABLE:
-            return(GC_malloc_atomic_uncollectable((size_t)lb));
+            return GC_malloc_atomic_uncollectable(lb);
 #       endif /* ATOMIC_UNCOLLECTABLE */
         default:
-            return(GC_generic_malloc(lb,knd));
+            return GC_generic_malloc(lb, knd);
     }
 }
 
@@ -177,7 +177,7 @@ GC_API void * GC_CALL GC_generic_malloc_ignore_off_page(size_t lb, int k)
     DCL_LOCK_STATE;
 
     if (SMALL_OBJ(lb))
-        return(GC_generic_malloc((word)lb, k));
+        return GC_generic_malloc(lb, k);
     lg = ROUNDED_UP_GRANULES(lb);
     lb_rounded = GRANULES_TO_BYTES(lg);
     if (lb_rounded < lb)
@@ -220,12 +220,12 @@ GC_API void * GC_CALL GC_generic_malloc_ignore_off_page(size_t lb, int k)
 
 GC_API void * GC_CALL GC_malloc_ignore_off_page(size_t lb)
 {
-    return((void *)GC_generic_malloc_ignore_off_page(lb, NORMAL));
+    return GC_generic_malloc_ignore_off_page(lb, NORMAL);
 }
 
 GC_API void * GC_CALL GC_malloc_atomic_ignore_off_page(size_t lb)
 {
-    return((void *)GC_generic_malloc_ignore_off_page(lb, PTRFREE));
+    return GC_generic_malloc_ignore_off_page(lb, PTRFREE);
 }
 
 /* Increment GC_bytes_allocd from code that doesn't have direct access  */