Changeset: c962529d920f for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=c962529d920f
Modified Files:
        monetdb5/mal/mal_resolve.c
Branch: default
Log Message:

Avoid malloc calls


diffs (42 lines):

diff --git a/monetdb5/mal/mal_resolve.c b/monetdb5/mal/mal_resolve.c
--- a/monetdb5/mal/mal_resolve.c
+++ b/monetdb5/mal/mal_resolve.c
@@ -184,6 +184,7 @@ findFunctionType(stream *out, Module sco
        int i, k, unmatched = 0, s1;
        /* int foundbutwrong=0; */
        int polytype[MAXTYPEVAR];
+       int returns[256];
        int *returntype = NULL;
        /*
         * Within a module find the subscope to locate the element in its list
@@ -206,7 +207,11 @@ findFunctionType(stream *out, Module sco
        if (s == 0)
                return -1;
 
-       returntype = (int *) GDKzalloc(p->retc * sizeof(int));
+       if ( p->retc < 256){
+               for(i=0; i< p->retc; i++) returns[i] = 0;
+               returntype = returns;
+       } else 
+               returntype = (int *) GDKzalloc(p->retc * sizeof(int));
        if (returntype == 0)
                return -1;
 
@@ -527,7 +532,7 @@ findFunctionType(stream *out, Module sco
                        mnstr_printf(out, "Finished matching\n");
                }
 #endif
-               if (returntype)
+               if (returntype && returntype != returns)
                        GDKfree(returntype);
                return s1;
        } /* while */
@@ -543,7 +548,7 @@ findFunctionType(stream *out, Module sco
                                                                "type conflict 
in assignment");
                }
         */
-       if (returntype)
+       if (returntype && returntype != returns)
                GDKfree(returntype);
        return -3;
 }
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to