Changeset: 401071ae7841 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=401071ae7841
Modified Files:
        gdk/gdk.h
        gdk/gdk_search.c
        gdk/gdk_search.h
Branch: default
Log Message:

make sure new types BUN[1248]type cannot be mistaken for old type BUN

This includes changing the type of struct "Hash" members "link" & "hash"
from BUN* to void*, as they are no longer meant to be used literally,
but always need to be cast to one of BUN[1248]type.

Also added type casts where required and removed them where redundant.


diffs (101 lines):

diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -556,14 +556,14 @@ typedef size_t BUN;
 #define BUN2 2
 #define BUN4 4
 #define BUN8 8
-typedef unsigned char BUN1type;
-typedef unsigned short BUN2type;
-typedef unsigned int BUN4type;
-typedef BUN BUN8type;
+typedef uint8_t  BUN1type;
+typedef uint16_t BUN2type;
+typedef uint32_t BUN4type;
+typedef uint64_t BUN8type;
 #define BUN1_NONE ((BUN1type) 0xFF)
 #define BUN2_NONE ((BUN2type) 0xFFFF)
 #define BUN4_NONE ((BUN4type) 0xFFFFFFFF)
-#define BUN8_NONE ((BUN8type) BUN_NONE)
+#define BUN8_NONE ((BUN8type) LL_CONSTANT(0xFFFFFFFFFFFFFFFF))
 
 
 /*
@@ -652,8 +652,8 @@ typedef struct {
        BUN nil;                /* nil representation */
        BUN lim;                /* collision list size */
        BUN mask;               /* number of hash buckets-1 (power of 2) */
-       BUN *hash;              /* hash table */
-       BUN *link;              /* collision list */
+       void *hash;             /* hash table */
+       void *link;             /* collision list */
        Heap *heap;             /* heap where the hash is stored */
 } Hash;
 
diff --git a/gdk/gdk_search.c b/gdk/gdk_search.c
--- a/gdk/gdk_search.c
+++ b/gdk/gdk_search.c
@@ -94,10 +94,9 @@
 
 static int
 HASHwidth(BUN hashsize){
-       if (hashsize <= BUN1_NONE) return BUN1;
-       if (hashsize <= BUN2_NONE) return BUN2;
-       if (hashsize <= BUN4_NONE) return BUN4;
-       (void) hashsize;
+       if (hashsize <= (BUN) BUN1_NONE) return BUN1;
+       if (hashsize <= (BUN) BUN2_NONE) return BUN2;
+       if (hashsize <= (BUN) BUN4_NONE) return BUN4;
        return BUN8;
 }
 
@@ -125,7 +124,7 @@ Hash *
 HASHnew(Heap *hp, int tpe, BUN size, BUN mask)
 {
        Hash *h = NULL;
-       int width = HASHwidth(MAX(mask,size));
+       int width = HASHwidth(size);
 
        if (HEAPalloc(hp, mask + size, width) < 0)
                return NULL;
@@ -138,22 +137,22 @@ HASHnew(Heap *hp, int tpe, BUN size, BUN
        h->width = width;
        switch (width) {
        case BUN1:
-               h->nil = BUN1_NONE;
+               h->nil = (BUN) BUN1_NONE;
                break;
        case BUN2:
-               h->nil = BUN2_NONE;
+               h->nil = (BUN) BUN2_NONE;
                break;
        case BUN4:
-               h->nil = BUN4_NONE;
+               h->nil = (BUN) BUN4_NONE;
                break;
        case BUN8:
-               h->nil = BUN8_NONE;
+               h->nil = (BUN) BUN8_NONE;
                break;
        default:
                assert(0);
        }
-       h->link = (BUN *) hp->base;
-       h->hash = (BUN *) ((char*)h->link + h->lim *width);
+       h->link = (void *) hp->base;
+       h->hash = (void *) ((char *) h->link + h->lim * width);
        h->type = tpe;
        h->heap = hp;
        HASHclear(h);           /* zero the mask */
diff --git a/gdk/gdk_search.h b/gdk/gdk_search.h
--- a/gdk/gdk_search.h
+++ b/gdk/gdk_search.h
@@ -34,7 +34,7 @@ gdk_export BUN HASHprobe(Hash *h, const 
 gdk_export BUN HASHlist(Hash *h, BUN i);
 
 
-#define HASHnil(H)  (BUN) (H->nil)
+#define HASHnil(H)     H->nil
 
 /* play around with h->hash[i] and h->link[j] */
 #define HASHget(h,i)   \
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to