Changeset: e636143bae82 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/e636143bae82
Modified Files:
        gdk/gdk_aggr.c
        gdk/gdk_calc.h
        monetdb5/modules/atoms/inet.c
        monetdb5/modules/atoms/str.c
        monetdb5/modules/atoms/streams.c
        monetdb5/modules/atoms/url.c
        monetdb5/modules/kernel/algebra.c
        monetdb5/modules/mal/calc.c
        monetdb5/modules/mal/clients.c
        monetdb5/modules/mal/manifold.c
        monetdb5/modules/mal/remote.c
        sql/backends/monet5/sql_cast.c
        sql/backends/monet5/sql_subquery.c
Branch: resource_management
Log Message:

wip using allocator in various mal modules


diffs (truncated from 1293 to 300 lines):

diff --git a/gdk/gdk_aggr.c b/gdk/gdk_aggr.c
--- a/gdk/gdk_aggr.c
+++ b/gdk/gdk_aggr.c
@@ -3567,7 +3567,7 @@ BATgroupmin(BAT *b, BAT *g, BAT *e, BAT 
 /* return pointer to smallest non-nil value in b, or pointer to nil if
  * there is no such value (no values at all, or only nil) */
 void *
-BATmin_skipnil(BAT *b, void *aggr, bit skipnil)
+BATmin_skipnil(allocator *alloc, BAT *b, void *aggr, bit skipnil)
 {
        const void *res = NULL;
        size_t s;
@@ -3698,7 +3698,7 @@ BATmin_skipnil(BAT *b, void *aggr, bit s
        }
        if (aggr == NULL) {
                s = ATOMlen(bi.type, res);
-               aggr = GDKmalloc(s);
+               aggr = alloc? sa_alloc(alloc, s) : GDKmalloc(s);
        } else {
                s = ATOMsize(ATOMtype(bi.type));
        }
@@ -3713,7 +3713,7 @@ BATmin_skipnil(BAT *b, void *aggr, bit s
 void *
 BATmin(BAT *b, void *aggr)
 {
-       return BATmin_skipnil(b, aggr, 1);
+       return BATmin_skipnil(NULL, b, aggr, 1);
 }
 
 BAT *
@@ -3724,7 +3724,7 @@ BATgroupmax(BAT *b, BAT *g, BAT *e, BAT 
 }
 
 void *
-BATmax_skipnil(BAT *b, void *aggr, bit skipnil)
+BATmax_skipnil(allocator *alloc, BAT *b, void *aggr, bit skipnil)
 {
        const void *res = NULL;
        size_t s;
@@ -3828,7 +3828,7 @@ BATmax_skipnil(BAT *b, void *aggr, bit s
        }
        if (aggr == NULL) {
                s = ATOMlen(bi.type, res);
-               aggr = GDKmalloc(s);
+               aggr = alloc? sa_alloc(alloc, s) : GDKmalloc(s);
        } else {
                s = ATOMsize(ATOMtype(bi.type));
        }
@@ -3843,7 +3843,7 @@ BATmax_skipnil(BAT *b, void *aggr, bit s
 void *
 BATmax(BAT *b, void *aggr)
 {
-       return BATmax_skipnil(b, aggr, 1);
+       return BATmax_skipnil(NULL, b, aggr, 1);
 }
 
 
diff --git a/gdk/gdk_calc.h b/gdk/gdk_calc.h
--- a/gdk/gdk_calc.h
+++ b/gdk/gdk_calc.h
@@ -148,8 +148,8 @@ gdk_export gdk_return BATsum(void *res, 
 gdk_export gdk_return BATprod(void *res, int tp, BAT *b, BAT *s, bool 
skip_nils, bool nil_if_empty);
 gdk_export void *BATmax(BAT *b, void *aggr);
 gdk_export void *BATmin(BAT *b, void *aggr);
-gdk_export void *BATmax_skipnil(BAT *b, void *aggr, bit skipnil);
-gdk_export void *BATmin_skipnil(BAT *b, void *aggr, bit skipnil);
+gdk_export void *BATmax_skipnil(allocator *alloc, BAT *b, void *aggr, bit 
skipnil);
+gdk_export void *BATmin_skipnil(allocator *alloc, BAT *b, void *aggr, bit 
skipnil);
 
 gdk_export dbl BATcalcstdev_population(dbl *avgp, BAT *b);
 gdk_export dbl BATcalcstdev_sample(dbl *avgp, BAT *b);
diff --git a/monetdb5/modules/atoms/inet.c b/monetdb5/modules/atoms/inet.c
--- a/monetdb5/modules/atoms/inet.c
+++ b/monetdb5/modules/atoms/inet.c
@@ -556,11 +556,11 @@ INEThost(Client ctx, str *retval, const 
        str ip;
 
        if (is_inet_nil(val)) {
-               *retval = GDKstrdup(str_nil);
+               *retval = MA_STRDUP(ctx->alloc, str_nil);
                if (*retval == NULL)
                        throw(MAL, "INEThost", SQLSTATE(HY013) MAL_MALLOC_FAIL);
        } else {
-               ip = GDKmalloc(sizeof(char) * 16);
+               ip = ma_alloc(ctx->alloc, sizeof(char) * 16);
                if (ip == NULL)
                        throw(MAL, "INEThost", SQLSTATE(HY013) MAL_MALLOC_FAIL);
                sprintf(ip, "%d.%d.%d.%d", val->q1, val->q2, val->q3, val->q4);
@@ -716,11 +716,11 @@ INETtext(Client ctx, str *retval, const 
        str ip;
 
        if (is_inet_nil(val)) {
-               *retval = GDKstrdup(str_nil);
+               *retval = MA_STRDUP(ctx->alloc, str_nil);
                if (*retval == NULL)
                        throw(MAL, "INETtext", SQLSTATE(HY013) MAL_MALLOC_FAIL);
        } else {
-               ip = GDKmalloc(sizeof(char) * 20);
+               ip = ma_alloc(ctx->alloc, sizeof(char) * 20);
                if (ip == NULL)
                        throw(MAL, "INETtext", SQLSTATE(HY013) MAL_MALLOC_FAIL);
 
@@ -743,7 +743,7 @@ INETabbrev(Client ctx, str *retval, cons
        str ip;
 
        if (is_inet_nil(val)) {
-               *retval = GDKstrdup(str_nil);
+               *retval = MA_STRDUP(ctx->alloc, str_nil);
                if (*retval == NULL)
                        throw(MAL, "inet.abbrev", SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
        } else {
@@ -777,7 +777,7 @@ INETabbrev(Client ctx, str *retval, cons
                 * all zero, thus no bits on the right side of the mask
                 */
 
-               ip = GDKmalloc(sizeof(char) * 20);
+               ip = ma_alloc(ctx->alloc, sizeof(char) * 20);
                if (ip == NULL)
                        throw(MAL, "inet.abbrev", SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
 
diff --git a/monetdb5/modules/atoms/str.c b/monetdb5/modules/atoms/str.c
--- a/monetdb5/modules/atoms/str.c
+++ b/monetdb5/modules/atoms/str.c
@@ -267,9 +267,9 @@ STRtostr(Client ctx, str *res, const cha
 {
        (void) ctx;
        if (*src == 0)
-               *res = GDKstrdup(str_nil);
+               *res = MA_STRDUP(ctx->alloc, str_nil);
        else
-               *res = GDKstrdup(*src);
+               *res = MA_STRDUP(ctx->alloc, *src);
        if (*res == NULL)
                throw(MAL, "str.str", SQLSTATE(HY013) MAL_MALLOC_FAIL);
        return MAL_SUCCEED;
@@ -319,7 +319,7 @@ STRTail(Client ctx, str *res, const char
        int off = *offset;
 
        if (strNil(s) || is_int_nil(off)) {
-               *res = GDKstrdup(str_nil);
+               *res = MA_STRDUP(ctx->alloc, str_nil);
        } else {
                size_t buflen = INITIAL_STR_BUFFER_LENGTH;
 
@@ -330,7 +330,7 @@ STRTail(Client ctx, str *res, const char
                        GDKfree(buf);
                        return msg;
                }
-               *res = GDKstrdup(buf);
+               *res = MA_STRDUP(ctx->alloc, buf);
        }
 
        GDKfree(buf);
@@ -376,7 +376,7 @@ STRSubString(Client ctx, str *res, const
        int off = *offset, len = *length;
 
        if (strNil(s) || is_int_nil(off) || is_int_nil(len)) {
-               *res = GDKstrdup(str_nil);
+               *res = MA_STRDUP(ctx->alloc, str_nil);
        } else {
                size_t buflen = INITIAL_STR_BUFFER_LENGTH;
 
@@ -387,7 +387,7 @@ STRSubString(Client ctx, str *res, const
                        GDKfree(buf);
                        return msg;
                }
-               *res = GDKstrdup(buf);
+               *res = MA_STRDUP(ctx->alloc, buf);
        }
 
        GDKfree(buf);
@@ -417,7 +417,7 @@ STRFromWChr(Client ctx, str *res, const 
        int cc = *c;
 
        if (is_int_nil(cc)) {
-               *res = GDKstrdup(str_nil);
+               *res = MA_STRDUP(ctx->alloc, str_nil);
        } else {
                size_t buflen = MAX(strlen(str_nil) + 1, 8);
 
@@ -428,7 +428,7 @@ STRFromWChr(Client ctx, str *res, const 
                        GDKfree(buf);
                        return msg;
                }
-               *res = GDKstrdup(buf);
+               *res = MA_STRDUP(ctx->alloc, buf);
        }
 
        GDKfree(buf);
@@ -471,12 +471,12 @@ STRWChrAt(Client ctx, int *res, const ch
 }
 
 static inline str
-doStrConvert(str *res, const char *arg1, gdk_return (*func)(char **restrict, 
size_t *restrict, const char *restrict))
+doStrConvert(allocator *alloc, str *res, const char *arg1, gdk_return 
(*func)(char **restrict, size_t *restrict, const char *restrict))
 {
        str buf = NULL, msg = MAL_SUCCEED;
 
        if (strNil(arg1)) {
-               *res = GDKstrdup(str_nil);
+               *res = MA_STRDUP(alloc, str_nil);
        } else {
                size_t buflen = INITIAL_STR_BUFFER_LENGTH;
 
@@ -487,7 +487,7 @@ doStrConvert(str *res, const char *arg1,
                        GDKfree(buf);
                        throw(MAL, "str.lower", GDK_EXCEPTION);
                }
-               *res = GDKstrdup(buf);
+               *res = MA_STRDUP(alloc, buf);
        }
 
        GDKfree(buf);
@@ -501,21 +501,21 @@ static inline str
 STRlower(Client ctx, str *res, const char *const *arg1)
 {
        (void) ctx;
-       return doStrConvert(res, *arg1, GDKtolower);
+       return doStrConvert(ctx->alloc, res, *arg1, GDKtolower);
 }
 
 static inline str
 STRupper(Client ctx, str *res, const char *const *arg1)
 {
        (void) ctx;
-       return doStrConvert(res, *arg1, GDKtoupper);
+       return doStrConvert(ctx->alloc, res, *arg1, GDKtoupper);
 }
 
 static inline str
 STRcasefold(Client ctx, str *res, const char *const *arg1)
 {
        (void) ctx;
-       return doStrConvert(res, *arg1, GDKcasefold);
+       return doStrConvert(ctx->alloc, res, *arg1, GDKcasefold);
 }
 
 /* returns whether arg1 starts with arg2 */
@@ -784,7 +784,7 @@ STRsplitpart(Client ctx, str *res, const
        int f = *field;
 
        if (strNil(s) || strNil(s2) || is_int_nil(f)) {
-               *res = GDKstrdup(str_nil);
+               *res = MA_STRDUP(ctx->alloc, str_nil);
        } else {
                size_t buflen = INITIAL_STR_BUFFER_LENGTH;
 
@@ -795,7 +795,7 @@ STRsplitpart(Client ctx, str *res, const
                        GDKfree(buf);
                        return msg;
                }
-               *res = GDKstrdup(buf);
+               *res = MA_STRDUP(ctx->alloc, buf);
        }
 
        GDKfree(buf);
@@ -908,7 +908,7 @@ STRStrip(Client ctx, str *res, const cha
        const char *s = *arg1;
 
        if (strNil(s)) {
-               *res = GDKstrdup(str_nil);
+               *res = MA_STRDUP(ctx->alloc, str_nil);
        } else {
                size_t buflen = INITIAL_STR_BUFFER_LENGTH;
 
@@ -919,7 +919,7 @@ STRStrip(Client ctx, str *res, const cha
                        GDKfree(buf);
                        return msg;
                }
-               *res = GDKstrdup(buf);
+               *res = MA_STRDUP(ctx->alloc, buf);
        }
 
        GDKfree(buf);
@@ -950,7 +950,7 @@ STRLtrim(Client ctx, str *res, const cha
        const char *s = *arg1;
 
        if (strNil(s)) {
-               *res = GDKstrdup(str_nil);
+               *res = MA_STRDUP(ctx->alloc, str_nil);
        } else {
                size_t buflen = INITIAL_STR_BUFFER_LENGTH;
 
@@ -961,7 +961,7 @@ STRLtrim(Client ctx, str *res, const cha
                        GDKfree(buf);
                        return msg;
                }
-               *res = GDKstrdup(buf);
+               *res = MA_STRDUP(ctx->alloc, buf);
        }
 
        GDKfree(buf);
@@ -992,7 +992,7 @@ STRRtrim(Client ctx, str *res, const cha
        const char *s = *arg1;
 
        if (strNil(s)) {
-               *res = GDKstrdup(str_nil);
+               *res = MA_STRDUP(ctx->alloc, str_nil);
        } else {
                size_t buflen = INITIAL_STR_BUFFER_LENGTH;
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to