[svn:parrot] r45493 - in trunk: include/parrot src

petdance at svn.parrot.org petdance at svn.parrot.org
Sat Apr 10 01:37:18 UTC 2010


Author: petdance
Date: Sat Apr 10 01:37:18 2010
New Revision: 45493
URL: https://trac.parrot.org/parrot/changeset/45493

Log:
fixing consting on args.  Localized some vars.

Modified:
   trunk/include/parrot/hash.h
   trunk/src/hash.c

Modified: trunk/include/parrot/hash.h
==============================================================================
--- trunk/include/parrot/hash.h	Sat Apr 10 01:23:04 2010	(r45492)
+++ trunk/include/parrot/hash.h	Sat Apr 10 01:37:18 2010	(r45493)
@@ -129,7 +129,7 @@
 PARROT_WARN_UNUSED_RESULT
 PARROT_CAN_RETURN_NULL
 void * parrot_hash_get(PARROT_INTERP,
-    ARGIN(Hash *hash),
+    ARGIN(const Hash *hash),
     ARGIN(const void *key))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2)
@@ -222,15 +222,13 @@
         __attribute__nonnull__(2);
 
 PARROT_CAN_RETURN_NULL
-void* hash_key_from_int(PARROT_INTERP,
-    ARGIN(const Hash * const hash),
-    INTVAL key)
+void* hash_key_from_int(PARROT_INTERP, ARGIN(const Hash *hash), INTVAL key)
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 
 PARROT_CAN_RETURN_NULL
 void* hash_key_from_pmc(PARROT_INTERP,
-    ARGIN(const Hash * const hash),
+    ARGIN(const Hash *hash),
     ARGIN(PMC *key))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2)
@@ -238,14 +236,14 @@
 
 PARROT_CAN_RETURN_NULL
 void* hash_key_from_string(PARROT_INTERP,
-    ARGIN(const Hash * const hash),
+    ARGIN(const Hash *hash),
     ARGIN(STRING *key))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2)
         __attribute__nonnull__(3);
 
 INTVAL hash_key_to_int(PARROT_INTERP,
-    ARGIN(const Hash * const hash),
+    ARGIN(const Hash *hash),
     ARGIN_NULLOK(void *key))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
@@ -260,61 +258,61 @@
 
 PARROT_CANNOT_RETURN_NULL
 STRING* hash_key_to_string(PARROT_INTERP,
-    ARGIN(const Hash * const hash),
+    ARGIN(const Hash *hash),
     ARGIN_NULLOK(void *key))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 
 PARROT_CAN_RETURN_NULL
 void* hash_value_from_int(PARROT_INTERP,
-    ARGIN(const Hash * const hash),
+    ARGIN(const Hash *hash),
     INTVAL value)
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 
 PARROT_CAN_RETURN_NULL
 void* hash_value_from_number(PARROT_INTERP,
-    ARGIN(const Hash * const hash),
+    ARGIN(const Hash *hash),
     FLOATVAL value)
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 
 PARROT_CAN_RETURN_NULL
 void* hash_value_from_pmc(PARROT_INTERP,
-    ARGIN(const Hash * const hash),
+    ARGIN(const Hash *hash),
     ARGIN_NULLOK(PMC *value))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 
 PARROT_CAN_RETURN_NULL
 void* hash_value_from_string(PARROT_INTERP,
-    ARGIN(const Hash * const hash),
+    ARGIN(const Hash *hash),
     ARGIN_NULLOK(STRING *value))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 
 INTVAL hash_value_to_int(PARROT_INTERP,
-    ARGIN(const Hash * const hash),
+    ARGIN(const Hash *hash),
     ARGIN_NULLOK(void *value))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 
 FLOATVAL hash_value_to_number(PARROT_INTERP,
-    ARGIN(const Hash * const hash),
+    ARGIN(const Hash *hash),
     ARGIN_NULLOK(void *value))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 
 PARROT_CANNOT_RETURN_NULL
 PMC* hash_value_to_pmc(PARROT_INTERP,
-    ARGIN(const Hash * const hash),
+    ARGIN(const Hash *hash),
     ARGIN_NULLOK(void *value))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);
 
 PARROT_CANNOT_RETURN_NULL
 STRING* hash_value_to_string(PARROT_INTERP,
-    ARGIN(const Hash * const hash),
+    ARGIN(const Hash *hash),
     ARGIN_NULLOK(void *value))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2);

Modified: trunk/src/hash.c
==============================================================================
--- trunk/src/hash.c	Sat Apr 10 01:23:04 2010	(r45492)
+++ trunk/src/hash.c	Sat Apr 10 01:37:18 2010	(r45493)
@@ -54,7 +54,7 @@
         FUNC_MODIFIES(*hash);
 
 static void hash_freeze(PARROT_INTERP,
-    ARGIN(const Hash * const hash),
+    ARGIN(const Hash *hash),
     ARGMOD(PMC *info))
         __attribute__nonnull__(1)
         __attribute__nonnull__(2)
@@ -604,13 +604,13 @@
             }
           case enum_hash_string:
             {
-                const STRING * s = VTABLE_shift_string(interp, info);
+                STRING * const s = VTABLE_shift_string(interp, info);
                 b->value = (void *)s;
                 break;
             }
           case enum_hash_pmc:
             {
-                PMC *p   = VTABLE_shift_pmc(interp, info);
+                PMC * const p = VTABLE_shift_pmc(interp, info);
                 b->value = (void *)p;
                 break;
             }
@@ -625,8 +625,7 @@
 
 /*
 
-=item C<static void hash_freeze(PARROT_INTERP, const Hash * const hash, PMC
-*info)>
+=item C<static void hash_freeze(PARROT_INTERP, const Hash *hash, PMC *info)>
 
 Freezes hash into a string.
 
@@ -640,7 +639,7 @@
 */
 
 static void
-hash_freeze(PARROT_INTERP, ARGIN(const Hash * const hash), ARGMOD(PMC *info))
+hash_freeze(PARROT_INTERP, ARGIN(const Hash *hash), ARGMOD(PMC *info))
 {
     ASSERT_ARGS(hash_freeze)
     size_t           i;
@@ -753,13 +752,13 @@
     ASSERT_ARGS(expand_hash)
     HashBucket  **old_bi, **new_bi;
     HashBucket   *bs, *b, *new_mem;
-    HashBucket   *old_offset = (HashBucket *)((char *)hash + sizeof (Hash));
+    HashBucket * const old_offset = (HashBucket *)((char *)hash + sizeof (Hash));
 
     void * const  old_mem    = hash->bs;
     const UINTVAL old_size   = hash->mask + 1;
     const UINTVAL new_size   = old_size << 1;
     const UINTVAL old_nb     = N_BUCKETS(old_size);
-    size_t        offset, i, new_loc;
+    size_t        offset, i;
 
     /*
        allocate some less buckets
@@ -817,8 +816,9 @@
      * as expand_hash is only called for that case).
      */
     if (offset) {
-        for (i = 0; i < old_size; ++i) {
-            HashBucket **next_p = new_bi + i;
+        size_t j;
+        for (j = 0; j < old_size; ++j) {
+            HashBucket **next_p = new_bi + j;
             while (*next_p) {
                 *next_p = (HashBucket *)((char *)*next_p + offset);
                 b       = *next_p;
@@ -830,11 +830,11 @@
     /* recalc bucket index */
     for (i = 0; i < old_size; ++i) {
         HashBucket **next_p = new_bi + i;
-        while (*next_p) {
-            b = *next_p;
+
+        while ((b = *next_p) != NULL) {
             /* rehash the bucket */
-            new_loc = (hash->hash_val)(interp, b->key, hash->seed) &
-                (new_size - 1);
+            const size_t new_loc =
+                (hash->hash_val)(interp, b->key, hash->seed) & (new_size - 1);
 
             if (i != new_loc) {
                 *next_p         = b->next;
@@ -1254,7 +1254,8 @@
 
 /*
 
-=item C<void * parrot_hash_get(PARROT_INTERP, Hash *hash, const void *key)>
+=item C<void * parrot_hash_get(PARROT_INTERP, const Hash *hash, const void
+*key)>
 
 Returns the value keyed by C<key>, or C<NULL> if no bucket is found.
 
@@ -1266,7 +1267,7 @@
 PARROT_WARN_UNUSED_RESULT
 PARROT_CAN_RETURN_NULL
 void *
-parrot_hash_get(PARROT_INTERP, ARGIN(Hash *hash), ARGIN(const void *key))
+parrot_hash_get(PARROT_INTERP, ARGIN(const Hash *hash), ARGIN(const void *key))
 {
     ASSERT_ARGS(parrot_hash_get)
     const HashBucket * const bucket = parrot_hash_get_bucket(interp, hash, key);
@@ -1341,7 +1342,6 @@
     if (bucket)
         bucket->value = value;
     else {
-
         bucket = hash->free_list;
 
         if (!bucket) {
@@ -1532,8 +1532,7 @@
 
 /*
 
-=item C<void* hash_key_from_int(PARROT_INTERP, const Hash * const hash, INTVAL
-key)>
+=item C<void* hash_key_from_int(PARROT_INTERP, const Hash *hash, INTVAL key)>
 
 Cast INTVAL to hash key.
 
@@ -1543,7 +1542,7 @@
 
 PARROT_CAN_RETURN_NULL
 void*
-hash_key_from_int(PARROT_INTERP, ARGIN(const Hash * const hash), INTVAL key)
+hash_key_from_int(PARROT_INTERP, ARGIN(const Hash *hash), INTVAL key)
 {
     ASSERT_ARGS(hash_key_from_int)
     void *ret;
@@ -1567,8 +1566,8 @@
 
 /*
 
-=item C<void* hash_key_from_string(PARROT_INTERP, const Hash * const hash,
-STRING *key)>
+=item C<void* hash_key_from_string(PARROT_INTERP, const Hash *hash, STRING
+*key)>
 
 Cast STRING to hash key.
 
@@ -1578,7 +1577,7 @@
 
 PARROT_CAN_RETURN_NULL
 void*
-hash_key_from_string(PARROT_INTERP, ARGIN(const Hash * const hash), ARGIN(STRING *key))
+hash_key_from_string(PARROT_INTERP, ARGIN(const Hash *hash), ARGIN(STRING *key))
 {
     ASSERT_ARGS(hash_key_from_string)
     void *ret;
@@ -1608,8 +1607,7 @@
 
 /*
 
-=item C<void* hash_key_from_pmc(PARROT_INTERP, const Hash * const hash, PMC
-*key)>
+=item C<void* hash_key_from_pmc(PARROT_INTERP, const Hash *hash, PMC *key)>
 
 Cast PMC* to hash key.
 
@@ -1619,7 +1617,7 @@
 
 PARROT_CAN_RETURN_NULL
 void*
-hash_key_from_pmc(PARROT_INTERP, ARGIN(const Hash * const hash), ARGIN(PMC *key))
+hash_key_from_pmc(PARROT_INTERP, ARGIN(const Hash *hash), ARGIN(PMC *key))
 {
     ASSERT_ARGS(hash_key_from_pmc)
     void *ret;
@@ -1676,8 +1674,7 @@
 
 /*
 
-=item C<INTVAL hash_key_to_int(PARROT_INTERP, const Hash * const hash, void
-*key)>
+=item C<INTVAL hash_key_to_int(PARROT_INTERP, const Hash *hash, void *key)>
 
 Cast hash key to INTVAL.
 
@@ -1686,7 +1683,7 @@
 */
 
 INTVAL
-hash_key_to_int(PARROT_INTERP, ARGIN(const Hash * const hash), ARGIN_NULLOK(void *key))
+hash_key_to_int(PARROT_INTERP, ARGIN(const Hash *hash), ARGIN_NULLOK(void *key))
 {
     ASSERT_ARGS(hash_key_to_int)
     INTVAL ret;
@@ -1709,8 +1706,7 @@
 
 /*
 
-=item C<STRING* hash_key_to_string(PARROT_INTERP, const Hash * const hash, void
-*key)>
+=item C<STRING* hash_key_to_string(PARROT_INTERP, const Hash *hash, void *key)>
 
 Cast hash key to STRING.
 
@@ -1720,7 +1716,7 @@
 
 PARROT_CANNOT_RETURN_NULL
 STRING*
-hash_key_to_string(PARROT_INTERP, ARGIN(const Hash * const hash), ARGIN_NULLOK(void *key))
+hash_key_to_string(PARROT_INTERP, ARGIN(const Hash *hash), ARGIN_NULLOK(void *key))
 {
     ASSERT_ARGS(hash_key_to_string)
     STRING *ret;
@@ -1782,7 +1778,7 @@
 
 /*
 
-=item C<void* hash_value_from_int(PARROT_INTERP, const Hash * const hash, INTVAL
+=item C<void* hash_value_from_int(PARROT_INTERP, const Hash *hash, INTVAL
 value)>
 
 Cast INTVAL to hash value.
@@ -1793,7 +1789,7 @@
 
 PARROT_CAN_RETURN_NULL
 void*
-hash_value_from_int(PARROT_INTERP, ARGIN(const Hash * const hash), INTVAL value)
+hash_value_from_int(PARROT_INTERP, ARGIN(const Hash *hash), INTVAL value)
 {
     ASSERT_ARGS(hash_value_from_int)
     void *ret;
@@ -1819,8 +1815,8 @@
 
 /*
 
-=item C<void* hash_value_from_string(PARROT_INTERP, const Hash * const hash,
-STRING *value)>
+=item C<void* hash_value_from_string(PARROT_INTERP, const Hash *hash, STRING
+*value)>
 
 Cast STRING to hash value.
 
@@ -1830,7 +1826,7 @@
 
 PARROT_CAN_RETURN_NULL
 void*
-hash_value_from_string(PARROT_INTERP, ARGIN(const Hash * const hash),
+hash_value_from_string(PARROT_INTERP, ARGIN(const Hash *hash),
         ARGIN_NULLOK(STRING *value))
 {
     ASSERT_ARGS(hash_value_from_string)
@@ -1862,8 +1858,7 @@
 
 /*
 
-=item C<void* hash_value_from_pmc(PARROT_INTERP, const Hash * const hash, PMC
-*value)>
+=item C<void* hash_value_from_pmc(PARROT_INTERP, const Hash *hash, PMC *value)>
 
 Cast PMC to hash value.
 
@@ -1873,7 +1868,7 @@
 
 PARROT_CAN_RETURN_NULL
 void*
-hash_value_from_pmc(PARROT_INTERP, ARGIN(const Hash * const hash),
+hash_value_from_pmc(PARROT_INTERP, ARGIN(const Hash *hash),
     ARGIN_NULLOK(PMC *value))
 {
     ASSERT_ARGS(hash_value_from_pmc)
@@ -1902,8 +1897,8 @@
 
 /*
 
-=item C<void* hash_value_from_number(PARROT_INTERP, const Hash * const hash,
-FLOATVAL value)>
+=item C<void* hash_value_from_number(PARROT_INTERP, const Hash *hash, FLOATVAL
+value)>
 
 Cast FLOATVAL to hash value.
 
@@ -1913,7 +1908,7 @@
 
 PARROT_CAN_RETURN_NULL
 void*
-hash_value_from_number(PARROT_INTERP, ARGIN(const Hash * const hash), FLOATVAL value)
+hash_value_from_number(PARROT_INTERP, ARGIN(const Hash *hash), FLOATVAL value)
 {
     ASSERT_ARGS(hash_value_from_number)
     void *ret;
@@ -1942,8 +1937,7 @@
 
 /*
 
-=item C<INTVAL hash_value_to_int(PARROT_INTERP, const Hash * const hash, void
-*value)>
+=item C<INTVAL hash_value_to_int(PARROT_INTERP, const Hash *hash, void *value)>
 
 Cast hash value to INTVAL.
 
@@ -1952,7 +1946,7 @@
 */
 
 INTVAL
-hash_value_to_int(PARROT_INTERP, ARGIN(const Hash * const hash), ARGIN_NULLOK(void *value))
+hash_value_to_int(PARROT_INTERP, ARGIN(const Hash *hash), ARGIN_NULLOK(void *value))
 {
     ASSERT_ARGS(hash_value_to_int)
     INTVAL ret;
@@ -1976,8 +1970,8 @@
 
 /*
 
-=item C<STRING* hash_value_to_string(PARROT_INTERP, const Hash * const hash,
-void *value)>
+=item C<STRING* hash_value_to_string(PARROT_INTERP, const Hash *hash, void
+*value)>
 
 Cast hash value to STRING.
 
@@ -1987,7 +1981,7 @@
 
 PARROT_CANNOT_RETURN_NULL
 STRING*
-hash_value_to_string(PARROT_INTERP, ARGIN(const Hash * const hash), ARGIN_NULLOK(void *value))
+hash_value_to_string(PARROT_INTERP, ARGIN(const Hash *hash), ARGIN_NULLOK(void *value))
 {
     ASSERT_ARGS(hash_value_to_string)
     STRING *ret;
@@ -2010,8 +2004,7 @@
 
 /*
 
-=item C<PMC* hash_value_to_pmc(PARROT_INTERP, const Hash * const hash, void
-*value)>
+=item C<PMC* hash_value_to_pmc(PARROT_INTERP, const Hash *hash, void *value)>
 
 Cast hash value to PMC.
 
@@ -2021,7 +2014,7 @@
 
 PARROT_CANNOT_RETURN_NULL
 PMC*
-hash_value_to_pmc(PARROT_INTERP, ARGIN(const Hash * const hash), ARGIN_NULLOK(void *value))
+hash_value_to_pmc(PARROT_INTERP, ARGIN(const Hash *hash), ARGIN_NULLOK(void *value))
 {
     ASSERT_ARGS(hash_value_to_pmc)
     PMC *ret;
@@ -2044,8 +2037,8 @@
 
 /*
 
-=item C<FLOATVAL hash_value_to_number(PARROT_INTERP, const Hash * const hash,
-void *value)>
+=item C<FLOATVAL hash_value_to_number(PARROT_INTERP, const Hash *hash, void
+*value)>
 
 Cast hash value to FLOATVAL.
 
@@ -2054,7 +2047,7 @@
 */
 
 FLOATVAL
-hash_value_to_number(PARROT_INTERP, ARGIN(const Hash * const hash), ARGIN_NULLOK(void *value))
+hash_value_to_number(PARROT_INTERP, ARGIN(const Hash *hash), ARGIN_NULLOK(void *value))
 {
     ASSERT_ARGS(hash_value_to_number)
     FLOATVAL ret;


More information about the parrot-commits mailing list