Changeset: 09624ee9110a for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=09624ee9110a Modified Files: monetdb5/mal/mal_instruction.c monetdb5/mal/mal_instruction.h Branch: default Log Message:
merging diffs (70 lines): 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 @@ -98,6 +98,10 @@ newMalBlk(int maxvars, int maxstmts) MalBlkPtr mb; VarPtr *v; + /* each MAL instruction implies at least on variable */ + if ( maxvars < maxstmts) + maxvars = maxvars; + v = (VarPtr *) GDKzalloc(sizeof(VarPtr) * maxvars); if (v == NULL) { GDKerror("newMalBlk:" MAL_MALLOC_FAIL); @@ -110,7 +114,6 @@ newMalBlk(int maxvars, int maxstmts) } mb->var = v; - mb->vtop = 0; mb->vsize = maxvars; mb->help = mb->binding = NULL; @@ -139,6 +142,36 @@ newMalBlk(int maxvars, int maxstmts) return mb; } +void +resizeMalBlk(MalBlkPtr mb, int maxstmt, int maxvar) +{ + int i; + + if ( maxvar < maxstmt) + maxvar = maxstmt; + if ( mb->ssize > maxstmt && mb->vsize > maxvar) + return ; + + mb->stmt = (InstrPtr *) GDKrealloc(mb->stmt, maxstmt * sizeof(InstrPtr)); + if ( mb->stmt == NULL) + GDKerror("resizeMalBlk:" MAL_MALLOC_FAIL); + for ( i = mb->ssize; i < maxstmt; i++) + mb->stmt[i] = 0; + mb->ssize = maxstmt; + + mb->var = (VarPtr*) GDKrealloc(mb->var, maxvar * sizeof (VarPtr)); + if ( mb->var == NULL) + GDKerror("resizeMalBlk:" MAL_MALLOC_FAIL); + for( i = mb->vsize; i < maxvar; i++) + mb->var[i] = 0; + mb->vsize = maxvar; + + if ( mb->profiler){ + mb->profiler = (ProfRecord *) GDKrealloc(mb->profiler, maxstmt * sizeof(ProfRecord)); + if (mb->profiler == NULL) + GDKerror("resizeMalBlk:" MAL_MALLOC_FAIL); + } +} /* The resetMalBlk code removes instructions, but without freeing the * space. This way the structure is prepared for re-use */ void diff --git a/monetdb5/mal/mal_instruction.h b/monetdb5/mal/mal_instruction.h --- a/monetdb5/mal/mal_instruction.h +++ b/monetdb5/mal/mal_instruction.h @@ -237,6 +237,7 @@ mal_export void printSignature(stream *f mal_export MalBlkPtr newMalBlk(int maxvars, int maxstmts); mal_export void resetMalBlk(MalBlkPtr mb, int stop); mal_export int newMalBlkStmt(MalBlkPtr mb, int maxstmts); +mal_export void resizeMalBlk(MalBlkPtr mb, int maxstmt, int maxvar); mal_export void prepareMalBlk(MalBlkPtr mb, str s); mal_export void freeMalBlk(MalBlkPtr mb); mal_export MalBlkPtr copyMalBlk(MalBlkPtr mb); _______________________________________________ checkin-list mailing list checkin-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/checkin-list