Changeset: ba9a0b5832d4 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/ba9a0b5832d4
Modified Files:
monetdb5/mal/mal_instruction.c
Branch: default
Log Message:
Merge with Dec2025 branch.
diffs (110 lines):
diff --git a/monetdb5/mal/mal.h b/monetdb5/mal/mal.h
--- a/monetdb5/mal/mal.h
+++ b/monetdb5/mal/mal.h
@@ -108,7 +108,8 @@ typedef struct SYMDEF {
struct SYMDEF *skip; /* skip to next different symbol */
const char *name;
int kind; /* what kind of symbol
*/
- bool allocated; /* allocated using mallocs or
compiled inside the binary */
+ bool allocated:1; /* allocated using mallocs or
compiled inside the binary */
+ bool fallocated:1; /* func contents was malloced */
struct MALBLK *def; /* the details of the MAL fcn */
mel_func *func;
} *Symbol, SymRecord;
diff --git a/monetdb5/mal/mal_instruction.c b/monetdb5/mal/mal_instruction.c
--- a/monetdb5/mal/mal_instruction.c
+++ b/monetdb5/mal/mal_instruction.c
@@ -75,6 +75,11 @@ freeSymbol(Symbol s)
freeMalBlk(s->def);
s->def = NULL;
} else if (s->allocated && s->func) {
+ if (s->fallocated) {
+ GDKfree(s->func->args);
+ GDKfree((void *) s->func->comment);
+ GDKfree((void *) s->func->cname);
+ }
GDKfree(s->func);
}
GDKfree(s);
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
@@ -1278,12 +1278,11 @@ cntArgsReturns(Client ctx, int *retc)
return cnt;
}
-static void
+static inline void
mf_destroy(mel_func *f)
{
if (f) {
- if (f->args)
- GDKfree(f->args);
+ GDKfree(f->args);
GDKfree(f);
}
}
@@ -1398,31 +1397,26 @@ fcnCommandPatternHeader(Client ctx, int
assert(kind == COMMANDsymbol || kind == PATTERNsymbol);
mel_func *curFunc = (mel_func*)GDKmalloc(sizeof(mel_func));
- if (curFunc)
- curFunc->args = NULL;
- if (curFunc && nargs)
+ if (curFunc == NULL) {
+ parseError(ctx, SQLSTATE(HY013) MAL_MALLOC_FAIL);
+ return NULL;
+ }
+ *curFunc = (mel_func) {
+ .command = kind == COMMANDsymbol,
+ .fcn = fnme,
+ .mod = modnme,
+ .retc = retc,
+ .argc = nargs,
+ };
+ if (nargs)
curFunc->args = (mel_arg*)GDKmalloc(sizeof(mel_arg)*nargs);
- if (ctx->curprg == NULL || ctx->curprg->def->errors || curFunc == NULL
|| (nargs && curFunc->args == NULL)) {
+ if (ctx->curprg == NULL || ctx->curprg->def->errors || (nargs &&
curFunc->args == NULL)) {
mf_destroy(curFunc);
parseError(ctx, SQLSTATE(HY013) MAL_MALLOC_FAIL);
return NULL;
}
- curFunc->fcn = fnme;
- curFunc->mod = modnme;
- curFunc->cname = NULL;
- curFunc->command = false;
- if (kind == COMMANDsymbol)
- curFunc->command = true;
- curFunc->unsafe = 0;
- curFunc->vargs = 0;
- curFunc->vrets = 0;
- curFunc->poly = 0;
- curFunc->retc = retc;
- curFunc->argc = nargs;
- curFunc->comment = NULL;
-
/* get calling parameters */
ch = currChar(ctx);
int i = retc;
@@ -1501,8 +1495,9 @@ fcnCommandPatternHeader(Client ctx, int
if ((ch = currChar(ctx)) != ',') {
if (ch == ')')
break;
+ mf_destroy(curFunc);
parseError(ctx, "',' expected\n");
- return curFunc;
+ return NULL;
} else {
nextChar(ctx); /* skip ',' */
i++;
@@ -1555,6 +1550,7 @@ parseCommandPattern(Client ctx, int kind
curPrg->func = curFunc;
curPrg->def = NULL;
curPrg->allocated = true;
+ curPrg->fallocated = true;
skipSpace(ctx);
if (MALkeyword(ctx, "address", 7)) {
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]