Changeset: 5f82446fb829 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/5f82446fb829
Modified Files:
        gdk/gdk.h
        gdk/gdk_analytic_func.c
        gdk/gdk_bat.c
        gdk/gdk_batop.c
        monetdb5/modules/atoms/json.c
        monetdb5/modules/kernel/algebra.c
        monetdb5/modules/kernel/batstr.c
        monetdb5/modules/mal/manifold.c
        monetdb5/modules/mal/tablet.c
        sql/backends/monet5/UDF/capi/capi.c
        sql/backends/monet5/sql_upgrades.c
        sql/storage/bat/bat_storage.c
        sql/storage/bat/bat_table.c
        sql/storage/sql_storage.h
        tools/monetdbe/monetdbe.c
Branch: default
Log Message:

Changed the BUNt* functions into ones that return const void *.


diffs (truncated from 413 to 300 lines):

diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -838,7 +838,7 @@ Tmskval(const BATiter *bi, BUN p)
 }
 
 __attribute__((__pure__))
-static inline void *
+static inline const void *
 BUNtmsk(BATiter *bi, BUN p)
 {
        bi->tmsk = Tmskval(bi, p);
@@ -846,15 +846,15 @@ BUNtmsk(BATiter *bi, BUN p)
 }
 
 __attribute__((__pure__))
-static inline void *
+static inline const void *
 BUNtloc(BATiter *bi, BUN p)
 {
        assert(bi->type != TYPE_msk);
-       return (void *) ((char *) bi->base + (p << bi->shift));
+       return (const void *) ((char *) bi->base + (p << bi->shift));
 }
 
 __attribute__((__pure__))
-static inline void *
+static inline const void *
 BUNtpos(BATiter *bi, BUN p)
 {
        assert(bi->base == NULL);
@@ -910,15 +910,15 @@ BUNtpos(BATiter *bi, BUN p)
 }
 
 __attribute__((__pure__))
-static inline void *
+static inline const void *
 BUNtvar(BATiter *bi, BUN p)
 {
        assert(bi->type && bi->vh);
-       return (void *) (bi->vh->base + VarHeapVal(bi->base, p, bi->width));
+       return (const void *) (bi->vh->base + VarHeapVal(bi->base, p, 
bi->width));
 }
 
 __attribute__((__pure__))
-static inline void *
+static inline const void *
 BUNtail(BATiter *bi, BUN p)
 {
        if (bi->type) {
@@ -960,7 +960,7 @@ BUNtoid(BAT *b, BUN p)
        /* b->tvheap != NULL, so we know there will be no parallel
         * modifications (so no locking) */
        BATiter bi = bat_iterator_nolock(b);
-       return * (oid *) BUNtpos(&bi, p);
+       return * (const oid *) BUNtpos(&bi, p);
 }
 
 gdk_export BUN BATcount_no_nil(BAT *b, BAT *s);
diff --git a/gdk/gdk_analytic_func.c b/gdk/gdk_analytic_func.c
--- a/gdk/gdk_analytic_func.c
+++ b/gdk/gdk_analytic_func.c
@@ -1213,7 +1213,7 @@ GDKanalyticallead(BAT *b, BAT *p, BUN le
                oid ncount = i - k;                                     \
                if ((res = GDKrebuild_segment_tree(ncount, sizeof(void*), st, 
&segment_tree, &levels_offset, &nlevels)) != GDK_SUCCEED) \
                        goto cleanup;                                   \
-               populate_segment_tree(void*, ncount, 
INIT_AGGREGATE_MIN_MAX_OTHERS, COMPUTE_LEVEL0_MIN_MAX_OTHERS, 
COMPUTE_LEVELN_MIN_MAX_OTHERS, GT_LT, NOTHING, NOTHING); \
+               populate_segment_tree(const void*, ncount, 
INIT_AGGREGATE_MIN_MAX_OTHERS, COMPUTE_LEVEL0_MIN_MAX_OTHERS, 
COMPUTE_LEVELN_MIN_MAX_OTHERS, GT_LT, NOTHING, NOTHING); \
                for (; k < i; k++)                                      \
                        compute_on_segment_tree(void*, start[k] - j, end[k] - 
j, INIT_AGGREGATE_MIN_MAX_OTHERS, COMPUTE_LEVELN_MIN_MAX_OTHERS, 
FINALIZE_AGGREGATE_MIN_MAX_OTHERS, GT_LT, NOTHING, NOTHING); \
                j = k;                                                  \
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -1539,8 +1539,8 @@ BUNinplacemulti(BAT *b, const oid *posit
 
                if (b->tvheap && b->ttype) {
                        var_t _d;
-                       ptr _ptr;
-                       _ptr = BUNtloc(&bi, p);
+                       void *_ptr;
+                       _ptr = b->theap->base + p * b->twidth;
                        switch (b->twidth) {
                        case 1:
                                _d = (var_t) * (uint8_t *) _ptr + GDK_VAROFFSET;
@@ -1583,7 +1583,7 @@ BUNinplacemulti(BAT *b, const oid *posit
                                bi.minpos = minpos;
                                bi.maxpos = maxpos;
                        }
-                       _ptr = BUNtloc(&bi, p);
+                       _ptr = b->theap->base + p * b->twidth;
                        switch (b->twidth) {
                        case 1:
                                * (uint8_t *) _ptr = (uint8_t) (_d - 
GDK_VAROFFSET);
@@ -1629,7 +1629,8 @@ BUNinplacemulti(BAT *b, const oid *posit
 #endif
                                break;
                        default:
-                               memcpy(BUNtloc(&bi, p), t, ATOMsize(b->ttype));
+                               memcpy(b->theap->base + p * ATOMsize(b->ttype),
+                                      t, ATOMsize(b->ttype));
                                break;
                        }
                }
diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c
--- a/gdk/gdk_batop.c
+++ b/gdk/gdk_batop.c
@@ -1853,7 +1853,8 @@ BATappend_or_update(BAT *b, BAT *p, cons
 #endif
                                break;
                        default:
-                               memcpy(BUNtloc(&bi, updid), new, 
ATOMsize(b->ttype));
+                               memcpy(b->theap->base + updid * b->twidth,
+                                      new, ATOMsize(b->ttype));
                                break;
                        }
                        HASHinsert_locked(&bi, updid, new);
diff --git a/monetdb5/modules/atoms/json.c b/monetdb5/modules/atoms/json.c
--- a/monetdb5/modules/atoms/json.c
+++ b/monetdb5/modules/atoms/json.c
@@ -2296,7 +2296,7 @@ JSONrenderRowObject(allocator *ma, BAT *
        int i, tpe;
        char *row, *row2, *name = 0, *val = 0;
        size_t len, lim, l;
-       void *p;
+       const void *p;
        BATiter bi;
 
        row = ma_alloc(ma, lim = BUFSIZ);
@@ -2412,7 +2412,7 @@ JSONrenderRowArray(Client ctx, BAT **bl,
        int i, tpe;
        char *row, *row2, *val = 0;
        size_t len, lim, l;
-       void *p;
+       const void *p;
        BATiter bi;
        allocator *ma = mb->ma;
 
@@ -2519,10 +2519,11 @@ JSONfoldKeyValue(Client ctx, str *ret, c
        BAT *bo = 0, *bk = 0, *bv;
        BATiter bki, bvi;
        int tpe;
-       char *row, *val = 0, *nme = 0;
+       char *row, *nme = NULL;
+       const char *val = NULL;
        BUN i, cnt;
        size_t len, lim, l;
-       void *p;
+       const void *p;
        oid o = 0;
        allocator *ma = ctx->curprg->def->ma;
 
@@ -2577,13 +2578,12 @@ JSONfoldKeyValue(Client ctx, str *ret, c
                        size_t osz = lim;
                        while (l + 3 > lim - len)
                                lim = (lim / (i + 1)) * cnt + BUFSIZ + l + 3;
-                       p = ma_realloc(ma, row, lim, osz);
-                       if (p == NULL) {
+                       row = ma_realloc(ma, row, lim, osz);
+                       if (row == NULL) {
                                bat_iterator_end(&bki);
                                bat_iterator_end(&bvi);
                                goto memfail;
                        }
-                       row = p;
                        if (!strNil(nme)) {
                                snprintf(row + len, lim - len, "\"%s\":", nme);
                                len += l + 3;
@@ -2607,13 +2607,12 @@ JSONfoldKeyValue(Client ctx, str *ret, c
                size_t osz = lim;
                while (l > lim - len)
                        lim = (lim / (i + 1)) * cnt + BUFSIZ + l + 3;
-               p = ma_realloc(ma, row, lim, osz);
-               if (p == NULL) {
+               row = ma_realloc(ma, row, lim, osz);
+               if (row == NULL) {
                        bat_iterator_end(&bki);
                        bat_iterator_end(&bvi);
                        goto memfail;
                }
-               row = p;
                strncpy(row + len, val ? val : "null", l);
                len += l;
                row[len++] = ',';
diff --git a/monetdb5/modules/kernel/algebra.c 
b/monetdb5/modules/kernel/algebra.c
--- a/monetdb5/modules/kernel/algebra.c
+++ b/monetdb5/modules/kernel/algebra.c
@@ -1556,7 +1556,7 @@ doALGfetch(allocator *ma, ptr ret, BAT *
        assert(pos <= BUN_MAX);
        BATiter bi = bat_iterator(b);
        if (ATOMextern(b->ttype)) {
-               ptr _src = BUNtail(&bi, pos);
+               const void *_src = BUNtail(&bi, pos);
                size_t _len = ATOMlen(b->ttype, _src);
                ptr _dst = ma_alloc(ma, _len);
                if (_dst == NULL) {
diff --git a/monetdb5/modules/kernel/batstr.c b/monetdb5/modules/kernel/batstr.c
--- a/monetdb5/modules/kernel/batstr.c
+++ b/monetdb5/modules/kernel/batstr.c
@@ -1920,8 +1920,8 @@ prefix_or_suffix(Client cntxt, MalBlkPtr
                for (BUN i = 0; i < ci1.ncand; i++) {
                        oid p1 = (canditer_next_dense(&ci1) - off1),
                                p2 = (canditer_next_dense(&ci2) - off2);
-                       char *x = BUNtvar(&lefti, p1);
-                       char *y = BUNtvar(&righti, p2);
+                       const char *x = BUNtvar(&lefti, p1);
+                       const char *y = BUNtvar(&righti, p2);
 
                        if (strNil(x) || strNil(y)) {
                                vals[i] = bit_nil;
@@ -1934,8 +1934,8 @@ prefix_or_suffix(Client cntxt, MalBlkPtr
                for (BUN i = 0; i < ci1.ncand; i++) {
                        oid p1 = (canditer_next(&ci1) - off1),
                                p2 = (canditer_next(&ci2) - off2);
-                       char *x = BUNtvar(&lefti, p1);
-                       char *y = BUNtvar(&righti, p2);
+                       const char *x = BUNtvar(&lefti, p1);
+                       const char *y = BUNtvar(&righti, p2);
 
                        if (strNil(x) || strNil(y)) {
                                vals[i] = bit_nil;
@@ -2044,7 +2044,7 @@ prefix_or_suffix_cst(Client cntxt, MalBl
        if (ci1.tpe == cand_dense) {
                for (BUN i = 0; i < ci1.ncand; i++) {
                        oid p1 = (canditer_next_dense(&ci1) - off1);
-                       char *x = BUNtvar(&bi, p1);
+                       const char *x = BUNtvar(&bi, p1);
 
                        if (ynil || strNil(x)) {
                                vals[i] = bit_nil;
@@ -2056,7 +2056,7 @@ prefix_or_suffix_cst(Client cntxt, MalBl
        } else {
                for (BUN i = 0; i < ci1.ncand; i++) {
                        oid p1 = (canditer_next(&ci1) - off1);
-                       char *x = BUNtvar(&bi, p1);
+                       const char *x = BUNtvar(&bi, p1);
 
                        if (ynil || strNil(x)) {
                                vals[i] = bit_nil;
@@ -2167,7 +2167,7 @@ prefix_or_suffix_strcst(Client cntxt, Ma
        if (ci1.tpe == cand_dense) {
                for (BUN i = 0; i < ci1.ncand; i++) {
                        oid p1 = (canditer_next_dense(&ci1) - off1);
-                       char *y = BUNtvar(&bi, p1);
+                       const char *y = BUNtvar(&bi, p1);
 
                        if (xnil || strNil(y)) {
                                vals[i] = bit_nil;
@@ -2179,7 +2179,7 @@ prefix_or_suffix_strcst(Client cntxt, Ma
        } else {
                for (BUN i = 0; i < ci1.ncand; i++) {
                        oid p1 = (canditer_next(&ci1) - off1);
-                       char *y = BUNtvar(&bi, p1);
+                       const char *y = BUNtvar(&bi, p1);
 
                        if (xnil || strNil(y)) {
                                vals[i] = bit_nil;
@@ -2296,8 +2296,8 @@ search_string_bat(Client cntxt, MalBlkPt
                for (BUN i = 0; i < ci1.ncand; i++) {
                        oid p1 = (canditer_next_dense(&ci1) - off1),
                                p2 = (canditer_next_dense(&ci2) - off2);
-                       char *x = BUNtvar(&lefti, p1);
-                       char *y = BUNtvar(&righti, p2);
+                       const char *x = BUNtvar(&lefti, p1);
+                       const char *y = BUNtvar(&righti, p2);
 
                        if (strNil(x) || strNil(y)) {
                                vals[i] = int_nil;
@@ -2310,8 +2310,8 @@ search_string_bat(Client cntxt, MalBlkPt
                for (BUN i = 0; i < ci1.ncand; i++) {
                        oid p1 = (canditer_next(&ci1) - off1),
                                p2 = (canditer_next(&ci2) - off2);
-                       char *x = BUNtvar(&lefti, p1);
-                       char *y = BUNtvar(&righti, p2);
+                       const char *x = BUNtvar(&lefti, p1);
+                       const char *y = BUNtvar(&righti, p2);
 
                        if (strNil(x) || strNil(y)) {
                                vals[i] = int_nil;
@@ -2417,7 +2417,7 @@ search_string_bat_cst(Client cntxt, MalB
        if (ci1.tpe == cand_dense) {
                for (BUN i = 0; i < ci1.ncand; i++) {
                        oid p1 = (canditer_next_dense(&ci1) - off1);
-                       char *x = BUNtvar(&bi, p1);
+                       const char *x = BUNtvar(&bi, p1);
 
                        if (ynil || strNil(x)) {
                                vals[i] = int_nil;
@@ -2429,7 +2429,7 @@ search_string_bat_cst(Client cntxt, MalB
        } else {
                for (BUN i = 0; i < ci1.ncand; i++) {
                        oid p1 = (canditer_next(&ci1) - off1);
-                       char *x = BUNtvar(&bi, p1);
+                       const char *x = BUNtvar(&bi, p1);
 
                        if (ynil || strNil(x)) {
                                vals[i] = int_nil;
@@ -2534,7 +2534,7 @@ search_string_bat_strcst(Client cntxt, M
        if (ci1.tpe == cand_dense) {
                for (BUN i = 0; i < ci1.ncand; i++) {
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to