Changeset: 4c2d8414b6aa for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=4c2d8414b6aa
Modified Files:
        monetdb5/optimizer/opt_mapreduce.mx
Branch: Aug2011
Log Message:

opt_mapreduce: don't use alloca


diffs (68 lines):

diff --git a/monetdb5/optimizer/opt_mapreduce.mx 
b/monetdb5/optimizer/opt_mapreduce.mx
--- a/monetdb5/optimizer/opt_mapreduce.mx
+++ b/monetdb5/optimizer/opt_mapreduce.mx
@@ -193,9 +193,9 @@
 
        assert(retc);
 
-       packs = (InstrPtr *)alloca(retc * sizeof(InstrPtr));
-       gets = (int *)alloca(n * retc * sizeof(int));
-       w = (int *)alloca(retc * sizeof(int));
+       packs = (InstrPtr *)GDKmalloc(retc * sizeof(InstrPtr));
+       gets = (int *)GDKmalloc(n * retc * sizeof(int));
+       w = (int *)GDKmalloc(retc * sizeof(int));
 
        for (lcol = col, j = 0; lcol != NULL; lcol = lcol->next, j++) {
                /* define and create the container bat for all results from the
@@ -356,6 +356,10 @@
        printFunction(cntxt->fdout, reduce, 0, LIST_MAL_STMT | LIST_MAPI);
 #endif
 
+       GDKfree(packs);
+       GDKfree(gets);
+       GDKfree(w);
+
        MRcleanCloud();
 }
 
@@ -475,7 +479,7 @@
                                                lastcol->reduceid = 
getArg(oreduce[i], 1);
                                                lastcol->type = getArgType(map, 
p, 1);
                                                lastcol->postop = SUM;
-                                               lastcol = lastcol->next = 
alloca(sizeof(mapcol));
+                                               lastcol = lastcol->next = 
GDKmalloc(sizeof(mapcol));
                                                lastcol->mapid = getArg(p, 2);
                                                lastcol->reduceid = 
getArg(oreduce[i], 2);
                                                lastcol->type = getArgType(map, 
p, 2);
@@ -694,7 +698,7 @@
                                                        /* this is a column 
reference, keep it */
                                                        MRaddDepInstrs(omap, 
limit, map, &instrp, p);
                                                        if (lastcol == NULL) {
-                                                               col = lastcol = 
alloca(sizeof(mapcol));
+                                                               col = lastcol = 
GDKmalloc(sizeof(mapcol));
                                                                /* this is the 
first one, leave a marker */
                                                                
oreduce[i]->token = REMsymbol;
                                                                
setModuleId(oreduce[i], mapreduceRef);
@@ -702,7 +706,7 @@
                                                                copy = LEAVE;
                                                        } else {
                                                                lastcol = 
lastcol->next =
-                                                                       
alloca(sizeof(mapcol));
+                                                                       
GDKmalloc(sizeof(mapcol));
                                                                /* push 
manually to get consistent
                                                                 * comment 
marking (after kdifference) */
                                                                
pushInstruction(map, p);
@@ -990,6 +994,13 @@
        printFunction(cntxt->fdout, reduce, 0, LIST_MAL_STMT | LIST_MAPI);
 #endif
 
+       lastcol = col;
+       while (lastcol != NULL) {
+               col = lastcol->next;
+               GDKfree(lastcol);
+               lastcol = col;
+       }
+
        GDKfree(omap);
        GDKfree(oreduce);
        trackstack_destroy(&tracker);
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to