Changeset: 4a79cec04849 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/4a79cec04849
Modified Files:
        monetdb5/modules/atoms/str.c
Branch: resource_management
Log Message:

favour MALblk allocator where possible


diffs (truncated from 751 to 300 lines):

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
@@ -266,11 +266,11 @@ STRlikewrap(Client ctx, bit *ret, const 
 static str
 STRtostr(Client ctx, str *res, const char *const *src)
 {
-       (void) ctx;
+       allocator *ma = ctx->curprg->def->ma;
        if (*src == 0)
-               *res = MA_STRDUP(ctx->alloc, str_nil);
+               *res = MA_STRDUP(ma, str_nil);
        else
-               *res = MA_STRDUP(ctx->alloc, *src);
+               *res = MA_STRDUP(ma, *src);
        if (*res == NULL)
                throw(MAL, "str.str", SQLSTATE(HY013) MAL_MALLOC_FAIL);
        return MAL_SUCCEED;
@@ -314,13 +314,13 @@ str_tail(str *buf, size_t *buflen, const
 static str
 STRTail(Client ctx, str *res, const char *const *arg1, const int *offset)
 {
-       (void) ctx;
+       allocator *ma = ctx->curprg->def->ma;
        str buf = NULL, msg = MAL_SUCCEED;
        const char *s = *arg1;
        int off = *offset;
 
        if (strNil(s) || is_int_nil(off)) {
-               *res = MA_STRDUP(ctx->alloc, str_nil);
+               *res = MA_STRDUP(ma, str_nil);
        } else {
                size_t buflen = INITIAL_STR_BUFFER_LENGTH;
 
@@ -331,7 +331,7 @@ STRTail(Client ctx, str *res, const char
                        GDKfree(buf);
                        return msg;
                }
-               *res = MA_STRDUP(ctx->alloc, buf);
+               *res = MA_STRDUP(ma, buf);
        }
 
        GDKfree(buf);
@@ -371,13 +371,13 @@ str_Sub_String(str *buf, size_t *buflen,
 static str
 STRSubString(Client ctx, str *res, const char *const *arg1, const int *offset, 
const int *length)
 {
-       (void) ctx;
+       allocator *ma = ctx->curprg->def->ma;
        str buf = NULL, msg = MAL_SUCCEED;
        const char *s = *arg1;
        int off = *offset, len = *length;
 
        if (strNil(s) || is_int_nil(off) || is_int_nil(len)) {
-               *res = MA_STRDUP(ctx->alloc, str_nil);
+               *res = MA_STRDUP(ma, str_nil);
        } else {
                size_t buflen = INITIAL_STR_BUFFER_LENGTH;
 
@@ -388,7 +388,7 @@ STRSubString(Client ctx, str *res, const
                        GDKfree(buf);
                        return msg;
                }
-               *res = MA_STRDUP(ctx->alloc, buf);
+               *res = MA_STRDUP(ma, buf);
        }
 
        GDKfree(buf);
@@ -413,12 +413,12 @@ str_from_wchr(str *buf, size_t *buflen, 
 static str
 STRFromWChr(Client ctx, str *res, const int *c)
 {
-       (void) ctx;
+       allocator *ma = ctx->curprg->def->ma;
        str buf = NULL, msg = MAL_SUCCEED;
        int cc = *c;
 
        if (is_int_nil(cc)) {
-               *res = MA_STRDUP(ctx->alloc, str_nil);
+               *res = MA_STRDUP(ma, str_nil);
        } else {
                size_t buflen = MAX(strlen(str_nil) + 1, 8);
 
@@ -429,7 +429,7 @@ STRFromWChr(Client ctx, str *res, const 
                        GDKfree(buf);
                        return msg;
                }
-               *res = MA_STRDUP(ctx->alloc, buf);
+               *res = MA_STRDUP(ma, buf);
        }
 
        GDKfree(buf);
@@ -472,12 +472,12 @@ STRWChrAt(Client ctx, int *res, const ch
 }
 
 static inline str
-doStrConvert(allocator *alloc, str *res, const char *arg1, gdk_return 
(*func)(char **restrict, size_t *restrict, const char *restrict))
+doStrConvert(allocator *ma, 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 = MA_STRDUP(alloc, str_nil);
+               *res = MA_STRDUP(ma, str_nil);
        } else {
                size_t buflen = INITIAL_STR_BUFFER_LENGTH;
 
@@ -488,7 +488,7 @@ doStrConvert(allocator *alloc, str *res,
                        GDKfree(buf);
                        throw(MAL, "str.lower", GDK_EXCEPTION);
                }
-               *res = MA_STRDUP(alloc, buf);
+               *res = MA_STRDUP(ma, buf);
        }
 
        GDKfree(buf);
@@ -501,22 +501,22 @@ doStrConvert(allocator *alloc, str *res,
 static inline str
 STRlower(Client ctx, str *res, const char *const *arg1)
 {
-       (void) ctx;
-       return doStrConvert(ctx->alloc, res, *arg1, GDKtolower);
+       allocator *ma = ctx->curprg->def->ma;
+       return doStrConvert(ma, res, *arg1, GDKtolower);
 }
 
 static inline str
 STRupper(Client ctx, str *res, const char *const *arg1)
 {
-       (void) ctx;
-       return doStrConvert(ctx->alloc, res, *arg1, GDKtoupper);
+       allocator *ma = ctx->curprg->def->ma;
+       return doStrConvert(ma, res, *arg1, GDKtoupper);
 }
 
 static inline str
 STRcasefold(Client ctx, str *res, const char *const *arg1)
 {
-       (void) ctx;
-       return doStrConvert(ctx->alloc, res, *arg1, GDKcasefold);
+       allocator *ma = ctx->curprg->def->ma;
+       return doStrConvert(ma, res, *arg1, GDKcasefold);
 }
 
 /* returns whether arg1 starts with arg2 */
@@ -579,9 +579,9 @@ str_icontains(const char *h, const char 
 }
 
 static str
-STRstartswith(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
+STRstartswith(Client ctx, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
 {
-       (void) cntxt;
+       (void) ctx;
        (void) mb;
 
        bit *r = getArgReference_bit(stk, pci, 0);
@@ -601,9 +601,9 @@ STRstartswith(Client cntxt, MalBlkPtr mb
 }
 
 static str
-STRendswith(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
+STRendswith(Client ctx, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
 {
-       (void) cntxt;
+       (void) ctx;
        (void) mb;
 
        bit *r = getArgReference_bit(stk, pci, 0);
@@ -624,9 +624,9 @@ STRendswith(Client cntxt, MalBlkPtr mb, 
 
 /* returns whether haystack contains needle */
 static str
-STRcontains(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
+STRcontains(Client ctx, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
 {
-       (void) cntxt;
+       (void) ctx;
        (void) mb;
 
        bit *r = getArgReference_bit(stk, pci, 0);
@@ -667,9 +667,9 @@ str_isearch(const char *haystack, const 
 
 /* find first occurrence of needle in haystack */
 static str
-STRstr_search(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
+STRstr_search(Client ctx, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
 {
-       (void) cntxt;
+       (void) ctx;
        (void) mb;
        bit *res = getArgReference(stk, pci, 0);
        const char *haystack = *getArgReference_str(stk, pci, 1);
@@ -722,9 +722,9 @@ str_reverse_str_isearch(const char *hays
 
 /* find last occurrence of arg2 in arg1 */
 static str
-STRrevstr_search(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
+STRrevstr_search(Client ctx, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
 {
-       (void) cntxt;
+       (void) ctx;
        (void) mb;
        int *res = getArgReference_int(stk, pci, 0);
        const str haystack = *getArgReference_str(stk, pci, 1);
@@ -779,13 +779,13 @@ str_splitpart(str *buf, size_t *buflen, 
 static str
 STRsplitpart(Client ctx, str *res, const char *const *haystack, const char 
*const *needle, const int *field)
 {
-       (void) ctx;
+       allocator *ma = ctx->curprg->def->ma;
        str buf = NULL, msg = MAL_SUCCEED;
        const char *s = *haystack, *s2 = *needle;
        int f = *field;
 
        if (strNil(s) || strNil(s2) || is_int_nil(f)) {
-               *res = MA_STRDUP(ctx->alloc, str_nil);
+               *res = MA_STRDUP(ma, str_nil);
        } else {
                size_t buflen = INITIAL_STR_BUFFER_LENGTH;
 
@@ -796,7 +796,7 @@ STRsplitpart(Client ctx, str *res, const
                        GDKfree(buf);
                        return msg;
                }
-               *res = MA_STRDUP(ctx->alloc, buf);
+               *res = MA_STRDUP(ma, buf);
        }
 
        GDKfree(buf);
@@ -904,12 +904,12 @@ str_strip(str *buf, size_t *buflen, cons
 static str
 STRStrip(Client ctx, str *res, const char *const *arg1)
 {
-       (void) ctx;
+       allocator *ma = ctx->curprg->def->ma;
        str buf = NULL, msg = MAL_SUCCEED;
        const char *s = *arg1;
 
        if (strNil(s)) {
-               *res = MA_STRDUP(ctx->alloc, str_nil);
+               *res = MA_STRDUP(ma, str_nil);
        } else {
                size_t buflen = INITIAL_STR_BUFFER_LENGTH;
 
@@ -920,7 +920,7 @@ STRStrip(Client ctx, str *res, const cha
                        GDKfree(buf);
                        return msg;
                }
-               *res = MA_STRDUP(ctx->alloc, buf);
+               *res = MA_STRDUP(ma, buf);
        }
 
        GDKfree(buf);
@@ -946,12 +946,12 @@ str_ltrim(str *buf, size_t *buflen, cons
 static str
 STRLtrim(Client ctx, str *res, const char *const *arg1)
 {
-       (void) ctx;
+       allocator *ma = ctx->curprg->def->ma;
        str buf = NULL, msg = MAL_SUCCEED;
        const char *s = *arg1;
 
        if (strNil(s)) {
-               *res = MA_STRDUP(ctx->alloc, str_nil);
+               *res = MA_STRDUP(ma, str_nil);
        } else {
                size_t buflen = INITIAL_STR_BUFFER_LENGTH;
 
@@ -962,7 +962,7 @@ STRLtrim(Client ctx, str *res, const cha
                        GDKfree(buf);
                        return msg;
                }
-               *res = MA_STRDUP(ctx->alloc, buf);
+               *res = MA_STRDUP(ma, buf);
        }
 
        GDKfree(buf);
@@ -988,12 +988,12 @@ str_rtrim(str *buf, size_t *buflen, cons
 static str
 STRRtrim(Client ctx, str *res, const char *const *arg1)
 {
-       (void) ctx;
+       allocator *ma = ctx->curprg->def->ma;
        str buf = NULL, msg = MAL_SUCCEED;
        const char *s = *arg1;
 
        if (strNil(s)) {
-               *res = MA_STRDUP(ctx->alloc, str_nil);
+               *res = MA_STRDUP(ma, str_nil);
        } else {
                size_t buflen = INITIAL_STR_BUFFER_LENGTH;
 
@@ -1004,7 +1004,7 @@ STRRtrim(Client ctx, str *res, const cha
                        GDKfree(buf);
                        return msg;
                }
-               *res = MA_STRDUP(ctx->alloc, buf);
+               *res = MA_STRDUP(ma, buf);
        }
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to