Changeset: 049410bd9716 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/049410bd9716
Modified Files:
monetdb5/mal/mal_exception.c
monetdb5/mal/mal_parser.c
monetdb5/modules/atoms/blob.c
monetdb5/modules/mal/inspect.c
monetdb5/modules/mal/mal_mapi.c
monetdb5/modules/mal/tablet.c
sql/backends/monet5/sql_rank.c
sql/server/sql_privileges.c
Branch: resource_management
Log Message:
mal exceptions use allocator
diffs (truncated from 1575 to 300 lines):
diff --git a/monetdb5/mal/mal_exception.c b/monetdb5/mal/mal_exception.c
--- a/monetdb5/mal/mal_exception.c
+++ b/monetdb5/mal/mal_exception.c
@@ -94,7 +94,9 @@ createExceptionInternal(enum malexceptio
TRC_CRITICAL(MAL_SERVER, "called with bad arguments");
len = 0;
}
- msg = GDKmalloc(msglen + len + 2);
+ allocator *ma = MT_thread_getallocator();
+ assert(ma);
+ msg = ma_alloc(ma, msglen + len + 2);
if (msg != NULL) {
/* the calls below succeed: the arguments have already been
checked */
(void) strconcat_len(msg, msglen + 1,
@@ -184,8 +186,9 @@ createException(enum malexception type,
void
freeException(str msg)
{
- if (msg != MAL_SUCCEED && msg != M5OutOfMemory)
- GDKfree(msg);
+ (void)msg;
+ //if (msg != MAL_SUCCEED && msg != M5OutOfMemory)
+ // GDKfree(msg);
}
/**
@@ -222,7 +225,9 @@ createMalExceptionInternal(MalBlkPtr mb,
int len = vsnprintf(NULL, 0, format, ap);
if (len < 0)
len = 0;
- char *msg = GDKmalloc(msglen + len + 1);
+ allocator *ma = MT_thread_getallocator();
+ assert(ma);
+ char *msg = ma_alloc(ma, msglen + len + 1);
if (msg != NULL) {
/* the calls below succeed: the arguments have already been
checked */
if (prev) {
diff --git a/monetdb5/mal/mal_parser.c b/monetdb5/mal/mal_parser.c
--- a/monetdb5/mal/mal_parser.c
+++ b/monetdb5/mal/mal_parser.c
@@ -30,7 +30,7 @@
#define FATALINPUT (MAXERRORS+1)
#define NL(X) ((X)=='\n' || (X)=='\r')
-static str idCopy(Client cntxt, int len);
+static str idCopy(allocator *ma, Client cntxt, int len);
static str strCopy(allocator *va, Client cntxt, int len);
/*
@@ -76,7 +76,7 @@ skipToEnd(Client cntxt)
* Keep on syntax error for reflection and correction.
*/
static void
-parseError(Client cntxt, str msg)
+parseError(allocator *ma, Client cntxt, str msg)
{
MalBlkPtr mb;
char *old, *new;
@@ -111,7 +111,7 @@ parseError(Client cntxt, str msg)
marker = createException(SYNTAX, "parseError", "%s%s", buf, msg);
old = mb->errors;
- new = GDKmalloc((old ? strlen(old) : 0) + strlen(line) + strlen(marker)
+
+ new = ma_alloc(ma, (old ? strlen(old) : 0) + strlen(line) +
strlen(marker) +
64);
if (new == NULL) {
freeException(line);
@@ -122,7 +122,7 @@ parseError(Client cntxt, str msg)
mb->errors = new;
if (old) {
new = stpcpy(new, old);
- GDKfree(old);
+ //GDKfree(old);
}
new = stpcpy(new, line);
new = stpcpy(new, marker);
@@ -383,9 +383,9 @@ typeidLength(Client cntxt)
}
static str
-idCopy(Client cntxt, int length)
+idCopy(allocator *ma, Client cntxt, int length)
{
- str s = GDKmalloc(length + 1);
+ str s = ma_alloc(ma, length + 1);
if (s == NULL)
return NULL;
memcpy(s, CURRENT(cntxt), (size_t) length);
@@ -533,7 +533,7 @@ operatorLength(Client cntxt)
* The constant structure is initialized for later use.
*/
static int
-cstToken(Client cntxt, MalBlkPtr mb, ValPtr cst)
+cstToken(allocator *ma, Client cntxt, MalBlkPtr mb, ValPtr cst)
{
int i = 0;
str s = CURRENT(cntxt);
@@ -610,7 +610,7 @@ cstToken(Client cntxt, MalBlkPtr mb, Val
size_t len = sizeof(flt);
float *pval = &cst->val.fval;
if (fltFromStr(CURRENT(cntxt), &len, &pval, false) < 0)
{
- parseError(cntxt, GDKerrbuf);
+ parseError(ma, cntxt, GDKerrbuf);
return i;
}
}
@@ -618,7 +618,7 @@ cstToken(Client cntxt, MalBlkPtr mb, Val
size_t len = sizeof(dbl);
double *pval = &cst->val.dval;
if (dblFromStr(CURRENT(cntxt), &len, &pval, false) < 0)
{
- parseError(cntxt, GDKerrbuf);
+ parseError(ma, cntxt, GDKerrbuf);
return i;
}
}
@@ -626,7 +626,7 @@ cstToken(Client cntxt, MalBlkPtr mb, Val
size_t len = sizeof(lng);
lng l, *pval = &l;
if (lngFromStr(CURRENT(cntxt), &len, &pval, false) < 0)
{
- parseError(cntxt, GDKerrbuf);
+ parseError(ma, cntxt, GDKerrbuf);
return i;
}
if (is_lng_nil(l) || l < 0
@@ -661,14 +661,14 @@ cstToken(Client cntxt, MalBlkPtr mb, Val
size_t len = sizeof(dbl);
dbl *pval = &cst->val.dval;
if (dblFromStr(CURRENT(cntxt), &len, &pval,
false) < 0) {
- parseError(cntxt, GDKerrbuf);
+ parseError(ma, cntxt, GDKerrbuf);
return i;
}
} else {
size_t len = sizeof(lng);
lng *pval = &cst->val.lval;
if (lngFromStr(CURRENT(cntxt), &len, &pval,
false) < 0) {
- parseError(cntxt, GDKerrbuf);
+ parseError(ma, cntxt, GDKerrbuf);
return i;
}
}
@@ -686,7 +686,7 @@ cstToken(Client cntxt, MalBlkPtr mb, Val
s++;
}
if (hgeFromStr(CURRENT(cntxt), &len, &pval, false) < 0)
{
- parseError(cntxt, GDKerrbuf);
+ parseError(ma, cntxt, GDKerrbuf);
return i;
}
return i;
@@ -776,7 +776,7 @@ cstToken(Client cntxt, MalBlkPtr mb, Val
* encoding tables, or type dependency should be modeled as properties.
*/
static int
-typeAlias(Client cntxt, int tpe)
+typeAlias(allocator *ma, Client cntxt, int tpe)
{
int t;
@@ -786,7 +786,7 @@ typeAlias(Client cntxt, int tpe)
nextChar(cntxt);
t = currChar(cntxt) - '0';
if (t <= 0 || t > 3) {
- parseError(cntxt, "[1-3] expected\n");
+ parseError(ma, cntxt, "[1-3] expected\n");
return -1;
} else
nextChar(cntxt);
@@ -800,7 +800,7 @@ typeAlias(Client cntxt, int tpe)
* We should change getMALtype to return a failure instead.
*/
static int
-simpleTypeId(Client cntxt)
+simpleTypeId(allocator *ma, Client cntxt)
{
int tpe;
size_t l;
@@ -808,7 +808,7 @@ simpleTypeId(Client cntxt)
nextChar(cntxt);
l = typeidLength(cntxt);
if (l == 0) {
- parseError(cntxt, "Type identifier expected\n");
+ parseError(ma, cntxt, "Type identifier expected\n");
cntxt->yycur--; /* keep it */
return -1;
}
@@ -817,7 +817,7 @@ simpleTypeId(Client cntxt)
else
tpe = getAtomIndex(CURRENT(cntxt), l, -1);
if (tpe < 0) {
- parseError(cntxt, "Type identifier expected\n");
+ parseError(ma, cntxt, "Type identifier expected\n");
cntxt->yycur -= l; /* keep it */
return TYPE_void;
}
@@ -826,7 +826,7 @@ simpleTypeId(Client cntxt)
}
static int
-parseTypeId(Client cntxt)
+parseTypeId(allocator *ma, Client cntxt)
{
int i = TYPE_any, kt = 0;
char *s = CURRENT(cntxt);
@@ -849,17 +849,17 @@ parseTypeId(Client cntxt)
if (!opt)
return newBatType(TYPE_any);
- parseError(cntxt, "':bat[:type]' expected\n");
+ parseError(ma, cntxt, "':bat[:type]' expected\n");
return -1;
}
advance(cntxt, 1);
if (currChar(cntxt) == ':') {
- tt = simpleTypeId(cntxt);
- kt = typeAlias(cntxt, tt);
+ tt = simpleTypeId(ma, cntxt);
+ kt = typeAlias(ma, cntxt, tt);
if (kt < 0)
return kt;
} else {
- parseError(cntxt, "':bat[:any]' expected\n");
+ parseError(ma, cntxt, "':bat[:any]' expected\n");
return -1;
}
@@ -871,30 +871,30 @@ parseTypeId(Client cntxt)
setOptBat(i);
if (currChar(cntxt) != ']')
- parseError(cntxt, "']' expected\n");
+ parseError(ma, cntxt, "']' expected\n");
nextChar(cntxt); // skip ']'
skipSpace(cntxt);
return i;
}
if (currChar(cntxt) == ':') {
- tt = simpleTypeId(cntxt);
- kt = typeAlias(cntxt, tt);
+ tt = simpleTypeId(ma, cntxt);
+ kt = typeAlias(ma, cntxt, tt);
if (kt < 0)
return kt;
if (kt > 0)
setTypeIndex(tt, kt);
return tt;
}
- parseError(cntxt, "<type identifier> expected\n");
+ parseError(ma, cntxt, "<type identifier> expected\n");
return -1;
}
static inline int
-typeElm(Client cntxt, int def)
+typeElm(allocator *ma, Client cntxt, int def)
{
if (currChar(cntxt) != ':')
return def; /* no type qualifier */
- return parseTypeId(cntxt);
+ return parseTypeId(ma, cntxt);
}
/*
@@ -934,7 +934,7 @@ typeElm(Client cntxt, int def)
* An atom statement does not introduce a new module.
*/
static void
-helpInfo(Client cntxt, allocator *va, str *help)
+helpInfo(allocator *ma, Client cntxt, allocator *va, str *help)
{
int l = 0;
char c, *e, *s;
@@ -958,15 +958,15 @@ helpInfo(Client cntxt, allocator *va, st
advance(cntxt, l - 1);
skipToEnd(cntxt);
} else {
- parseError(cntxt, "<string> expected\n");
+ parseError(ma, cntxt, "<string> expected\n");
}
}
} else if (currChar(cntxt) != ';')
- parseError(cntxt, "';' expected\n");
+ parseError(ma, cntxt, "';' expected\n");
}
static InstrPtr
-binding(Client cntxt, MalBlkPtr curBlk, InstrPtr curInstr, int flag)
+binding(allocator *ma, Client cntxt, MalBlkPtr curBlk, InstrPtr curInstr, int
flag)
{
int l, varid = -1;
malType type;
@@ -979,26 +979,26 @@ binding(Client cntxt, MalBlkPtr curBlk,
advance(cntxt, l);
if (varid < 0)
return curInstr;
- type = typeElm(cntxt, TYPE_any);
+ type = typeElm(ma, cntxt, TYPE_any);
if (type < 0)
return curInstr;
if (isPolymorphic(type))
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]