Changeset: 1d9254101525 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/1d9254101525
Modified Files:
monetdb5/modules/mal/mdb.c
monetdb5/modules/mal/orderidx.c
monetdb5/modules/mal/remote.c
Branch: resource_management
Log Message:
MALblk allocator in few other mal modules
diffs (truncated from 410 to 300 lines):
diff --git a/monetdb5/modules/mal/mdb.c b/monetdb5/modules/mal/mdb.c
--- a/monetdb5/modules/mal/mdb.c
+++ b/monetdb5/modules/mal/mdb.c
@@ -356,7 +356,7 @@ MDBStkTrace(Client cntxt, MalBlkPtr m, M
throw(MAL, "mdb.getStackTrace", SQLSTATE(HY013)
MAL_MALLOC_FAIL);
}
len = strlen(msg);
- buf = (char *) GDKmalloc(len + 1024);
+ buf = (char *) ma_alloc(m->ma, len + 1024);
if (buf == NULL) {
//GDKfree(msg);
BBPreclaim(b);
@@ -369,7 +369,7 @@ MDBStkTrace(Client cntxt, MalBlkPtr m, M
if (BUNappend(b, &k, false) != GDK_SUCCEED ||
BUNappend(bn, buf, false) != GDK_SUCCEED) {
//GDKfree(msg);
- GDKfree(buf);
+ //GDKfree(buf);
BBPreclaim(b);
BBPreclaim(bn);
throw(MAL, "mdb.setTrace", SQLSTATE(HY013) MAL_MALLOC_FAIL);
@@ -386,9 +386,9 @@ MDBStkTrace(Client cntxt, MalBlkPtr m, M
}
l = strlen(msg);
if (l > len) {
- GDKfree(buf);
+ //GDKfree(buf);
len = l;
- buf = (char *) GDKmalloc(len + 1024);
+ buf = (char *) ma_alloc(m->ma, len + 1024);
if (buf == NULL) {
//GDKfree(msg);
BBPunfix(b->batCacheid);
@@ -401,7 +401,7 @@ MDBStkTrace(Client cntxt, MalBlkPtr m, M
getFunctionId(getInstrPtr(s->blk, 0)), pcup);
if (BUNappend(b, &k, false) != GDK_SUCCEED ||
BUNappend(bn, buf, false) != GDK_SUCCEED) {
- GDKfree(buf);
+ //GDKfree(buf);
//GDKfree(msg);
BBPunfix(b->batCacheid);
BBPunfix(bn->batCacheid);
@@ -409,7 +409,7 @@ MDBStkTrace(Client cntxt, MalBlkPtr m, M
}
//GDKfree(msg);
}
- GDKfree(buf);
+ //GDKfree(buf);
*ret = b->batCacheid;
BBPkeepref(b);
*ret2 = bn->batCacheid;
@@ -673,7 +673,7 @@ MDBgetDefinition(Client cntxt, MalBlkPtr
static str
MDBgetExceptionVariable(Client ctx, str *ret, const char *const *msg)
{
- (void) ctx;
+ allocator *ma = ctx->curprg->def->ma;
str tail;
tail = strchr(*msg, ':');
@@ -682,7 +682,7 @@ MDBgetExceptionVariable(Client ctx, str
OPERATION_FAILED " ':'<name> missing");
*tail = 0;
- *ret = GDKstrdup(*msg);
+ *ret = MA_STRDUP(ma, *msg);
if (*ret == NULL)
throw(MAL, "mdb.getExceptionVariable", SQLSTATE(HY013)
MAL_MALLOC_FAIL);
*tail = ':';
@@ -692,7 +692,7 @@ MDBgetExceptionVariable(Client ctx, str
static str
MDBgetExceptionContext(Client ctx, str *ret, const char *const *msg)
{
- (void) ctx;
+ allocator *ma = ctx->curprg->def->ma;
str tail, tail2;
tail = strchr(*msg, ':');
@@ -705,7 +705,7 @@ MDBgetExceptionContext(Client ctx, str *
OPERATION_FAILED " <name> missing");
*tail2 = 0;
- *ret = GDKstrdup(tail + 1);
+ *ret = MA_STRDUP(ma, tail + 1);
if (*ret == NULL)
throw(MAL, "mdb.getExceptionContext", SQLSTATE(HY013)
MAL_MALLOC_FAIL);
*tail2 = ':';
@@ -715,7 +715,7 @@ MDBgetExceptionContext(Client ctx, str *
static str
MDBgetExceptionReason(Client ctx, str *ret, const char *const *msg)
{
- (void) ctx;
+ allocator *ma = ctx->curprg->def->ma;
str tail;
tail = strchr(*msg, ':');
@@ -725,7 +725,7 @@ MDBgetExceptionReason(Client ctx, str *r
if (tail == 0)
throw(MAL, "mdb.getExceptionReason", OPERATION_FAILED " ':'
missing");
- *ret = GDKstrdup(tail + 1);
+ *ret = MA_STRDUP(ma, tail + 1);
if (*ret == NULL)
throw(MAL, "mdb.getExceptionReason", SQLSTATE(HY013)
MAL_MALLOC_FAIL);
return MAL_SUCCEED;
diff --git a/monetdb5/modules/mal/orderidx.c b/monetdb5/modules/mal/orderidx.c
--- a/monetdb5/modules/mal/orderidx.c
+++ b/monetdb5/modules/mal/orderidx.c
@@ -395,7 +395,7 @@ OIDXmerge(Client cntxt, MalBlkPtr mb, Ma
throw(MAL, "bat.orderidx", TYPE_NOT_SUPPORTED);
}
- if ((a = (BAT **) GDKmalloc(n_ar * sizeof(BAT *))) == NULL) {
+ if ((a = (BAT **) ma_alloc(mb->ma, n_ar * sizeof(BAT *))) == NULL) {
BBPunfix(bid);
throw(MAL, "bat.orderidx", SQLSTATE(HY013) MAL_MALLOC_FAIL);
}
@@ -406,7 +406,7 @@ OIDXmerge(Client cntxt, MalBlkPtr mb, Ma
for (j = i - 1; j >= 0; j--) {
BBPunfix(a[j]->batCacheid);
}
- GDKfree(a);
+ //GDKfree(a);
BBPunfix(bid);
throw(MAL, "bat.orderidx", SQLSTATE(HY002)
RUNTIME_OBJECT_MISSING);
}
@@ -429,7 +429,7 @@ OIDXmerge(Client cntxt, MalBlkPtr mb, Ma
BBPunfix(bid);
for (i = 0; i < n_ar; i++)
BBPunfix(a[i]->batCacheid);
- GDKfree(a);
+ //GDKfree(a);
throw(MAL, "bat.orderidx", "count mismatch");
}
@@ -437,7 +437,7 @@ OIDXmerge(Client cntxt, MalBlkPtr mb, Ma
for (i = 0; i < n_ar; i++)
BBPunfix(a[i]->batCacheid);
- GDKfree(a);
+ //GDKfree(a);
BBPunfix(bid);
if (rc != GDK_SUCCEED)
diff --git a/monetdb5/modules/mal/remote.c b/monetdb5/modules/mal/remote.c
--- a/monetdb5/modules/mal/remote.c
+++ b/monetdb5/modules/mal/remote.c
@@ -318,9 +318,9 @@ RMTconnectScen(Client ctx, str *ret,
}
static str
-RMTconnect(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
+RMTconnect(Client ctx, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
{
- (void) cntxt;
+ (void) ctx;
(void) mb;
str *ret = getArgReference_str(stk, pci, 0);
const char *uri = *getArgReference_str(stk, pci, 1);
@@ -332,7 +332,7 @@ RMTconnect(Client cntxt, MalBlkPtr mb, M
if (pci->argc >= 5)
scen = *getArgReference_str(stk, pci, 4);
- return RMTconnectScen(cntxt, ret, &uri, &user, &passwd, &scen, NULL);
+ return RMTconnectScen(ctx, ret, &uri, &user, &passwd, &scen, NULL);
}
/**
@@ -341,9 +341,9 @@ RMTconnect(Client cntxt, MalBlkPtr mb, M
* created).
*/
str
-RMTdisconnect(Client cntxt, void *ret, const char *const *conn)
+RMTdisconnect(Client ctx, void *ret, const char *const *conn)
{
- (void) cntxt;
+ (void) ctx;
connection c, t;
if (conn == NULL || *conn == NULL || strcmp(*conn, (str) str_nil) == 0)
@@ -753,7 +753,7 @@ RMTinternalcopyfrom(BAT **ret, char *hdr
* We are only interested in retrieving void-headed BATs, i.e. single columns.
*/
static str
-RMTget(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
+RMTget(Client ctx, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
{
str conn, ident, tmp, rt;
connection c;
@@ -763,7 +763,7 @@ RMTget(Client cntxt, MalBlkPtr mb, MalSt
ValPtr v;
(void) mb;
- (void) cntxt;
+ (void) ctx;
conn = *getArgReference_str(stk, pci, 1);
if (conn == NULL || strcmp(conn, (str) str_nil) == 0)
@@ -956,7 +956,7 @@ RMTget(Client cntxt, MalBlkPtr mb, MalSt
* object on the remote host is returned for later use.
*/
static str
-RMTput(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
+RMTput(Client ctx, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
{
str conn, tmp;
char ident[512];
@@ -966,7 +966,7 @@ RMTput(Client cntxt, MalBlkPtr mb, MalSt
ptr value;
MapiHdl mhdl = NULL;
- (void) cntxt;
+ (void) ctx;
allocator *ma = mb->ma;
conn = *getArgReference_str(stk, pci, 1);
@@ -1141,7 +1141,7 @@ RMTput(Client cntxt, MalBlkPtr mb, MalSt
* followed by remote parsing.
*/
static str
-RMTregisterInternal(Client cntxt, char **fcn_id, const char *conn,
+RMTregisterInternal(Client ctx, char **fcn_id, const char *conn,
const char *mod, const char *fcn)
{
str tmp, qry, msg;
@@ -1155,7 +1155,7 @@ RMTregisterInternal(Client cntxt, char *
ILLEGAL_ARGUMENT ": connection name is NULL or nil");
/* find local definition */
- sym = findSymbol(cntxt->usermodule, putName(mod), putName(fcn));
+ sym = findSymbol(ctx->usermodule, putName(mod), putName(fcn));
if (sym == NULL)
throw(MAL, "remote.register",
ILLEGAL_ARGUMENT ": no such function: %s.%s", mod,
fcn);
@@ -1225,7 +1225,7 @@ RMTregisterInternal(Client cntxt, char *
setFunctionId(getInstrPtr(prg->def, 0), putName(*fcn_id));
/* make sure the program is error free */
- msg = chkProgram(cntxt->usermodule, prg->def);
+ msg = chkProgram(ctx->usermodule, prg->def);
if (msg != MAL_SUCCEED || prg->def->errors) {
MT_lock_unset(&c->lock);
if (msg)
@@ -1248,14 +1248,14 @@ RMTregisterInternal(Client cntxt, char *
}
static str
-RMTregister(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
+RMTregister(Client ctx, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
{
char **fcn_id = getArgReference_str(stk, pci, 0);
const char *conn = *getArgReference_str(stk, pci, 1);
const char *mod = *getArgReference_str(stk, pci, 2);
const char *fcn = *getArgReference_str(stk, pci, 3);
(void) mb;
- return RMTregisterInternal(cntxt, fcn_id, conn, mod, fcn);
+ return RMTregisterInternal(ctx, fcn_id, conn, mod, fcn);
}
/**
@@ -1268,7 +1268,7 @@ RMTregister(Client cntxt, MalBlkPtr mb,
* a get call. It handles multiple return arguments.
*/
static str
-RMTexec(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
+RMTexec(Client ctx, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
{
str conn, mod, func, tmp;
int i;
@@ -1277,7 +1277,7 @@ RMTexec(Client cntxt, MalBlkPtr mb, MalS
char *qbuf;
MapiHdl mhdl;
- (void) cntxt;
+ (void) ctx;
(void) mb;
bool no_return_arguments = 0;
@@ -1340,7 +1340,7 @@ RMTexec(Client cntxt, MalBlkPtr mb, MalS
}
len += 2;
buflen = len + 1;
- if ((qbuf = GDKmalloc(buflen)) == NULL) {
+ if ((qbuf = ma_alloc(mb->ma, buflen)) == NULL) {
MT_lock_unset(&c->lock);
throw(MAL, "remote.exec", SQLSTATE(HY013) MAL_MALLOC_FAIL);
}
@@ -1379,7 +1379,7 @@ RMTexec(Client cntxt, MalBlkPtr mb, MalS
len += snprintf(&qbuf[len], buflen - len, ");");
TRC_DEBUG(MAL_REMOTE, "Remote exec: %s - %s\n", c->name, qbuf);
tmp = RMTquery(&mhdl, "remote.exec", c->mconn, qbuf);
- GDKfree(qbuf);
+ //GDKfree(qbuf);
/* Temporary hack:
* use a callback to immediately handle columnar results before hdl is
destroyed. */
@@ -1387,7 +1387,7 @@ RMTexec(Client cntxt, MalBlkPtr mb, MalS
&& (mapi_get_querytype(mhdl) == Q_TABLE
|| mapi_get_querytype(mhdl) == Q_PREPARE)) {
int fields = mapi_get_field_count(mhdl);
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]