Changeset: ca802bfa5caa for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ca802bfa5caa
Modified Files:
monetdb5/mal/mal_authorize.c
monetdb5/mal/mal_recycle.c
monetdb5/mal/mal_stack.c
Branch: default
Log Message:
Merge with Aug2011 branch.
diffs (truncated from 1102 to 300 lines):
diff --git a/monetdb5/mal/mal_authorize.c b/monetdb5/mal/mal_authorize.c
--- a/monetdb5/mal/mal_authorize.c
+++ b/monetdb5/mal/mal_authorize.c
@@ -1021,55 +1021,56 @@
*/
static str
AUTHhashPassword(str *ret, str *algo, str *password, str *challenge) {
- str tmp;
+ str tmp = MAL_SUCCEED;
int len = (int) (strlen(*password) + strlen(*challenge));
- str key = alloca(sizeof(char) * (len + 1));
+ str key = GDKmalloc(sizeof(char) * (len + 1));
snprintf(key, len + 1, "%s%s", *password, *challenge);
#ifdef HAVE_RIPEMD160
if (strcmp(*algo, "RIPEMD160") == 0) {
- rethrow("hashPassword", tmp, AUTHRIPEMD160Sum(ret, &key, &len));
+ tmp = AUTHRIPEMD160Sum(ret, &key, &len);
} else
#endif
#ifdef HAVE_SHA512
if (strcmp(*algo, "SHA512") == 0) {
int bits = 512;
- rethrow("hashPassword", tmp, AUTHSHA2Sum(ret, &key, &len,
&bits));
+ tmp = AUTHSHA2Sum(ret, &key, &len, &bits);
} else
#endif
#ifdef HAVE_SHA384
if (strcmp(*algo, "SHA384") == 0) {
int bits = 384;
- rethrow("hashPassword", tmp, AUTHSHA2Sum(ret, &key, &len,
&bits));
+ tmp = AUTHSHA2Sum(ret, &key, &len, &bits);
} else
#endif
#ifdef HAVE_SHA256
if (strcmp(*algo, "SHA256") == 0) {
int bits = 256;
- rethrow("hashPassword", tmp, AUTHSHA2Sum(ret, &key, &len,
&bits));
+ tmp = AUTHSHA2Sum(ret, &key, &len, &bits);
} else
#endif
#ifdef HAVE_SHA224
if (strcmp(*algo, "SHA224") == 0) {
int bits = 224;
- rethrow("hashPassword", tmp, AUTHSHA2Sum(ret, &key, &len,
&bits));
+ tmp = AUTHSHA2Sum(ret, &key, &len, &bits);
} else
#endif
#ifdef HAVE_SHA1
if (strcmp(*algo, "SHA1") == 0) {
- rethrow("hashPassword", tmp, AUTHSHA1Sum(ret, &key, &len));
+ tmp = AUTHSHA1Sum(ret, &key, &len);
} else
#endif
#ifdef HAVE_MS5
if (strcmp(*algo, "MD5") == 0) {
- rethrow("hashPassword", tmp, AUTHMD5Sum(ret, &key, &len));
+ tmp = AUTHMD5Sum(ret, &key, &len);
} else
#endif
{
throw(MAL, "hashPassword", "unsupported hash type: '%s'",
*algo);
}
- return(MAL_SUCCEED);
+ GDKfree(key);
+ return(tmp);
}
/**
diff --git a/monetdb5/mal/mal_recycle.c b/monetdb5/mal/mal_recycle.c
--- a/monetdb5/mal/mal_recycle.c
+++ b/monetdb5/mal/mal_recycle.c
@@ -420,8 +420,7 @@
(void) cntxt;
- wben = (dbl *)alloca(sizeof(dbl)*ltop);
- memset(wben,0, sizeof(dbl)*ltop);
+ wben = (dbl *)GDKzalloc(sizeof(dbl)*ltop);
for (l = 0; l < ltop; l++){
sz = recycleBlk->profiler[lvs[l]].wbytes;
switch(rcachePolicy){
@@ -434,8 +433,10 @@
wben[l] = sz? ben / sz : -1;
totmem += sz;
}
- if (totmem <= wr) /* all leaves need to be dropped */
+ if (totmem <= wr) { /* all leaves need to be dropped */
+ GDKfree(wben);
return ltop;
+ }
/* reorder instructions on increasing weighted credit */
/* knapsack: find a set with biggest wben fitting in totmem-wr.
@@ -501,6 +502,7 @@
mnstr_printf(cntxt->fdout,"Don't drop critical item :
instruction %d, credit %f\n" ,tmpl,ci_ben);
#endif
}
+ GDKfree(wben);
return newtop;
}
diff --git a/monetdb5/mal/mal_resolve.mx b/monetdb5/mal/mal_resolve.mx
--- a/monetdb5/mal/mal_resolve.mx
+++ b/monetdb5/mal/mal_resolve.mx
@@ -130,11 +130,13 @@
}
#endif
-static malType findFunctionType(Module scope, MalBlkPtr mb, InstrPtr p,int
silent){
+static malType
+findFunctionType(Module scope, MalBlkPtr mb, InstrPtr p, int silent)
+{
Module m;
Symbol s;
InstrPtr sig;
- int i,k, unmatched = 0, s1;
+ int i, k, unmatched = 0, s1;
/* int foundbutwrong=0;*/
int polytype[MAXTYPEVAR];
int *returntype;
@@ -155,164 +157,164 @@
* it will be looked up multiple types to resolve the instruction.[todo]
* Simplify polytype using a map into the concrete argument table.
*/
- m= scope;
- s= m->subscope[(int)(getSubScope(getFunctionId(p)))];
- if( s == 0) return -1;
- while(s != NULL){ /* single scope element check */
- if( getFunctionId(p) != s->name ){
- s= s->skip; continue;
- }
- /*
- * @-
- * Perform a strong type-check on the actual arguments. If it turns
- * out to be a polymorphic MAL function, we have to clone it.
- * Provided the actual/formal parameters are compliant throughout
- * the function call.
- *
- * Also look out for variable argument lists. This means that we
- * have to keep two iterators, one for the caller (i) and one for
- * the callee (k). Since a variable argument only occurs as the last
one,
- * we simple avoid an increment when running out of formal arguments.
- *
- * A call of the form (X1,..., Xi) := f(Y1,....,Yn) can be matched
against
- * the function signature (B1,...,Bk):= f(A1,...,Am) where i==k , n<=m
- * and type(Ai)=type(Yi). Furthermore, the variables Xi obtain their
type
- * from Bi (or type(Bi)==type(Xi)).
- */
- sig = getSignature(s);
- unmatched = 0;
+ m = scope;
+ s = m->subscope[(int)(getSubScope(getFunctionId(p)))];
+ if (s == 0) return -1;
+ while (s != NULL) { /* single scope element check */
+ if (getFunctionId(p) != s->name) {
+ s = s->skip; continue;
+ }
+ /*
+ * @-
+ * Perform a strong type-check on the actual arguments. If it
turns
+ * out to be a polymorphic MAL function, we have to clone it.
+ * Provided the actual/formal parameters are compliant
throughout
+ * the function call.
+ *
+ * Also look out for variable argument lists. This means that we
+ * have to keep two iterators, one for the caller (i) and one
for
+ * the callee (k). Since a variable argument only occurs as the
last one,
+ * we simple avoid an increment when running out of formal
arguments.
+ *
+ * A call of the form (X1,..., Xi) := f(Y1,....,Yn) can be
matched against
+ * the function signature (B1,...,Bk):= f(A1,...,Am) where i==k
, n<=m
+ * and type(Ai)=type(Yi). Furthermore, the variables Xi obtain
their type
+ * from Bi (or type(Bi)==type(Xi)).
+ */
+ sig = getSignature(s);
+ unmatched = 0;
#ifdef DEBUG_MAL_RESOLVE
- if(tracefcn) {
- mnstr_printf(GDKout,"-->resolving\n");
- printInstruction(GDKout,mb,0,p,LIST_MAL_ALL);
- mnstr_printf(GDKout,"++> test against signature\n");
- printInstruction(GDKout,s->def,0,getSignature(s),LIST_MAL_ALL);
- mnstr_printf(GDKout," %s \n", sig->polymorphic?"polymorphic":"");
- }
+ if (tracefcn) {
+ mnstr_printf(GDKout, "-->resolving\n");
+ printInstruction(GDKout, mb, 0, p, LIST_MAL_ALL);
+ mnstr_printf(GDKout, "++> test against signature\n");
+ printInstruction(GDKout, s->def, 0, getSignature(s),
LIST_MAL_ALL);
+ mnstr_printf(GDKout, " %s \n", sig->polymorphic ?
"polymorphic" : "");
+ }
#endif
- /*
- * @-
- * The simple case could be taken care of separately to speedup
processing
- * However, it turned out not to make a big difference.
- * The first time we encounter a polymorphic argument in the
- * signature.
- * Subsequently, the polymorphic arguments update this table
- * and check for any type mismatches that might occur.
- * There are at most 2 type variables involved per argument
- * due to the limited type nesting permitted.
- * Note, each function returns at least one value.
- */
- if( sig->polymorphic ){
- int limit = sig->polymorphic;
- if( ! (sig->argc== p->argc ||
- (sig->argc<p->argc && sig->varargs & (VARARGS | VARRETS) ))
- ){
- s= s->peer; continue;
- }
- if( sig->retc != p->retc && !(sig->varargs & VARRETS)) {
- s= s->peer;
- continue;
- }
-/* if(polyVector[0]==0) polyInit();
- memcpy(polytype,polyVector, 2*sig->argc*sizeof(int)); */
-
- for(k=0; k< limit; k++) polytype[k] = TYPE_any;
- /*
- * @-
- * Most polymorphic functions don;t have a variable argument
- * list. So we save some instructions factoring this caise out.
- * Be careful, the variable number of return arguments should
- * be considered as well.
- */
- i= p->retc;
- /* first handle the variable argument list */
- for(k=sig->retc; i<p->argc; k++, i++){
- int actual = getArgType(mb,p,i);
- int formal = getArgType(s->def,sig,k);
- if (k == sig->argc-1 && sig->varargs & VARARGS)
- k--;
/*
* @-
- * Take care of variable argument lists.
- * They are allowed as the last in the signature only.
- * Furthermore, for patterns if the formal type is 'any' then
all remaining arguments
- * are acceptable and detailed type analysis becomes part of
the pattern
- * implementation.
- * In all other cases the type should apply to all remaining
arguments.
+ * The simple case could be taken care of separately to speedup
processing
+ * However, it turned out not to make a big difference.
+ * The first time we encounter a polymorphic argument in the
+ * signature.
+ * Subsequently, the polymorphic arguments update this table
+ * and check for any type mismatches that might occur.
+ * There are at most 2 type variables involved per argument
+ * due to the limited type nesting permitted.
+ * Note, each function returns at least one value.
*/
- if (formal == actual)
- continue;
- if( updateTypeMap(formal, actual, polytype)){
- unmatched= i;
- break;
- }
- formal= getPolyType(formal,polytype);
- /*
- * @-
- * Collect the polymorphic types and resolve them.
- * If it fails, we know this isn;t the function we are
- * looking for.
- */
- if( resolveType( formal,actual) == -1 ){
- unmatched= i;
- break;
- }
- }
- /*
- * @-
- * The last argument/result type could be a polymorphic variable list.
- * It should only be allowed for patterns, where it can deal with the
stack.
- * If the type is specified as :any then any mix of arguments is
allowed.
- * If the type is a new numbered type variable then the first element
- * in the list determines the required type of all.
- */
- if( sig->varargs ) {
- if( sig->token != PATTERNsymbol )
- unmatched = i;
- else {
- /* resolve the arguments */
- for(; i<p->argc; i++){
- /* the type of the last one has already been
set */
- int actual = getArgType(mb,p,i);
- int formal = getArgType(s->def,sig,k);
- if (k == sig->argc-1 && sig->varargs & VARARGS)
+ if (sig->polymorphic) {
+ int limit = sig->polymorphic;
+ if (!(sig->argc == p->argc ||
+ (sig->argc < p->argc && sig->varargs &
(VARARGS | VARRETS)))
+ ) {
+ s = s->peer; continue;
+ }
+ if (sig->retc != p->retc && !(sig->varargs & VARRETS)) {
+ s = s->peer;
+ continue;
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list