Changeset: 08d84d86f0c4 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=08d84d86f0c4 Modified Files: monetdb5/mal/mal_authorize.c monetdb5/mal/mal_instruction.c monetdb5/mal/mal_listing.c monetdb5/mal/mal_module.c monetdb5/modules/atoms/batxml.c monetdb5/modules/atoms/mtime.c monetdb5/modules/kernel/array.c monetdb5/modules/kernel/batstr.c monetdb5/modules/mal/inspect.c monetdb5/modules/mal/mal_mapi.c monetdb5/modules/mal/pcre.c monetdb5/modules/mal/remote.c monetdb5/modules/mal/tablet.c monetdb5/scheduler/run_octopus.c Branch: default Log Message:
Merge with Jan2014 branch (with some fixed merge conflicts). diffs (truncated from 1066 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 @@ -593,7 +593,7 @@ AUTHgetPasswordHash(str *ret, Client *c, /* decypher the password */ rethrow("changePassword", tmp, AUTHdecypherValue(&passwd, &tmp)); - *ret = GDKstrdup(passwd); + *ret = passwd; return(NULL); } @@ -645,8 +645,7 @@ AUTHdecypherValue(str *ret, str *value) */ /* this is the XOR decypher implementation */ - str r = GDKmalloc(sizeof(char) * (strlen(*value) + 1)); - str w = r; + str r, w; str s = *value; char t = '\0'; int escaped = 0; @@ -654,10 +653,11 @@ AUTHdecypherValue(str *ret, str *value) * (a space would only uppercase the password) */ int keylen = 0; + if (vaultKey == NULL) + throw(MAL, "decypherValue", "The vault is still locked!"); + w = r = GDKmalloc(sizeof(char) * (strlen(*value) + 1)); if( r == NULL) throw(MAL, "decypherValue", MAL_MALLOC_FAIL); - if (vaultKey == NULL) - throw(MAL, "decypherValue", "The vault is still locked!"); keylen = (int) strlen(vaultKey); @@ -688,17 +688,17 @@ AUTHdecypherValue(str *ret, str *value) static str AUTHcypherValue(str *ret, str *value) { /* this is the XOR cypher implementation */ - str r = GDKmalloc(sizeof(char) * (strlen(*value) * 2 + 1)); - str w = r; + str r, w; str s = *value; /* we default to some garbage key, just to make password unreadable * (a space would only uppercase the password) */ int keylen = 0; + if (vaultKey == NULL) + throw(MAL, "cypherValue", "The vault is still locked!"); + w = r = GDKmalloc(sizeof(char) * (strlen(*value) * 2 + 1)); if( r == NULL) throw(MAL, "cypherValue", MAL_MALLOC_FAIL); - if (vaultKey == NULL) - throw(MAL, "cypherValue", "The vault is still locked!"); keylen = (int) strlen(vaultKey); 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 @@ -142,8 +142,13 @@ newMalBlk(int maxvars, int maxstmts) mb->runtime = 0; mb->calls = 0; mb->optimize = 0; - if (newMalBlkStmt(mb, maxstmts) < 0) + mb->stmt = NULL; + if (newMalBlkStmt(mb, maxstmts) < 0) { + GDKfree(mb->var); + GDKfree(mb->stmt); + GDKfree(mb); return NULL; + } return mb; } diff --git a/monetdb5/mal/mal_listing.c b/monetdb5/mal/mal_listing.c --- a/monetdb5/mal/mal_listing.c +++ b/monetdb5/mal/mal_listing.c @@ -644,7 +644,7 @@ mal2str(MalBlkPtr mb, int flg, int first len = GDKmalloc(sizeof(int) * mb->stop); if( txt == NULL || len == NULL){ - GDKerror("mal2str"MAL_MALLOC_FAIL); + GDKerror("mal2str: " MAL_MALLOC_FAIL); if( txt ) GDKfree(txt); if( len ) GDKfree(len); return NULL; @@ -656,18 +656,19 @@ mal2str(MalBlkPtr mb, int flg, int first } ps = GDKmalloc(totlen + mb->stop + 1); if( ps == NULL) - GDKerror("mal2str"MAL_MALLOC_FAIL); + GDKerror("mal2str: " MAL_MALLOC_FAIL); totlen = 0; - for (i = first; i < last; i++) - if( txt[i]){ - if( ps){ - strncpy(ps + totlen, txt[i], len[i]); - ps[totlen + len[i]] = '\n'; - ps[totlen + len[i] + 1] = 0; - totlen += len[i] + 1; + for (i = first; i < last; i++) { + if( txt[i]){ + if( ps){ + strncpy(ps + totlen, txt[i], len[i]); + ps[totlen + len[i]] = '\n'; + ps[totlen + len[i] + 1] = 0; + totlen += len[i] + 1; + } + GDKfree(txt[i]); } - GDKfree(txt[i]); } GDKfree(len); GDKfree(txt); diff --git a/monetdb5/mal/mal_module.c b/monetdb5/mal/mal_module.c --- a/monetdb5/mal/mal_module.c +++ b/monetdb5/mal/mal_module.c @@ -629,15 +629,20 @@ showHelp(Module m, str txt, stream *fs){ char **msg = getHelp(m,txt,TRUE); if( msg == NULL) return; - for(i=0; msg[i]; i++) + for(i=0; msg[i]; i++) { mnstr_printf(fs,"%s\n",msg[i]); + GDKfree(msg[i]); + } + GDKfree(msg); if( i == 0){ msg = getHelp(m,txt,0); - for(i=0; msg[i]; i++){ - mnstr_printf(fs,"%s\n",msg[i]); - GDKfree(msg[i]); + if (msg) { + for(i=0; msg[i]; i++) { + mnstr_printf(fs,"%s\n",msg[i]); + GDKfree(msg[i]); + } + GDKfree(msg); } - GDKfree(msg); } } /* diff --git a/monetdb5/modules/atoms/batxml.c b/monetdb5/modules/atoms/batxml.c --- a/monetdb5/modules/atoms/batxml.c +++ b/monetdb5/modules/atoms/batxml.c @@ -77,13 +77,12 @@ batxml_export str AGGRsubxmlcand(bat *re batxml_export str AGGRsubxml(bat *retval, bat *bid, bat *gid, bat *eid, bit *skip_nils); -#define prepareResult(X,Y,tpe,Z, Freeup) \ - assert((Y)->htype == TYPE_void); \ - (X) = BATnew(TYPE_void, (tpe), BATcount(Y), TRANSIENT); \ +#define prepareResult(X,Y,tpe,Z,free) \ + (X) = BATnew((Y)->htype, (tpe), BATcount(Y), TRANSIENT); \ if ((X) == NULL) { \ BBPreleaseref((Y)->batCacheid); \ - Freeup; \ - throw(MAL, "xml." Z, MAL_MALLOC_FAIL); \ + free; \ + throw(MAL, "xml." Z, MAL_MALLOC_FAIL); \ } \ BATseqbase((X), (Y)->hseqbase); \ (X)->hsorted = (Y)->hsorted; \ @@ -109,7 +108,7 @@ BATXMLxml2str(bat *ret, const bat *bid) if ((b = BATdescriptor(*bid)) == NULL) throw(MAL, "xml.str", INTERNAL_BAT_ACCESS); - prepareResult(bn, b, TYPE_str, "str",); + prepareResult(bn, b, TYPE_str, "str", (void) 0); bi = bat_iterator(b); BATloop(b, p, q) { const void *h = (const void *) BUNhead(bi, p); @@ -146,7 +145,7 @@ BATXMLxmltext(bat *ret, const bat *bid) if ((b = BATdescriptor(*bid)) == NULL) throw(MAL, "xml.text", INTERNAL_BAT_ACCESS); - prepareResult(bn, b, TYPE_str, "text",); + prepareResult(bn, b, TYPE_str, "text", (void) 0); bi = bat_iterator(b); BATloop(b, p, q) { const void *h = (const void *) BUNhead(bi, p); @@ -256,7 +255,7 @@ BATXMLstr2xml(bat *ret, const bat *bid) GDKfree(buf); throw(MAL, "xml.xml", INTERNAL_BAT_ACCESS); } - prepareResult(bn, b, TYPE_xml, "xml",GDKfree(buf)); + prepareResult(bn, b, TYPE_xml, "xml", GDKfree(buf)); bi = bat_iterator(b); BATloop(b, p, q) { const void *h = (const void *) BUNhead(bi, p); @@ -440,7 +439,7 @@ BATXMLisdocument(bat *ret, const bat *bi if ((b = BATdescriptor(*bid)) == NULL) throw(MAL, "xml.isdocument", INTERNAL_BAT_ACCESS); - prepareResult(bn, b, TYPE_bit, "isdocument",); + prepareResult(bn, b, TYPE_bit, "isdocument", (void) 0); bi = bat_iterator(b); BATloop(b, p, q) { const void *h = (const void *) BUNhead(bi, p); @@ -505,7 +504,7 @@ BATXMLoptions(bat *ret, const char * con GDKfree(buf); throw(MAL, "xml.options", INTERNAL_BAT_ACCESS); } - prepareResult(bn, b, TYPE_xml, "options", GDKfree(buf);GDKfree(val)); + prepareResult(bn, b, TYPE_xml, "options", GDKfree(val); GDKfree(buf)); if (strcmp(*options, "absent") == 0) buf[0] = 0; @@ -980,7 +979,9 @@ BATXMLforest(Client cntxt, MalBlkPtr mb, throw(MAL, "xml.forest", INTERNAL_BAT_ACCESS); } - prepareResult(bn, bi[pci->retc].b, TYPE_xml, "forest", GDKfree(bi);GDKfree(p);GDKfree(q);GDKfree(buf)); + prepareResult(bn, bi[pci->retc].b, TYPE_xml, "forest", + for (i = pci->retc; i < pci->argc; i++) BBPunfix(bi[i].b->batCacheid); + GDKfree(bi); GDKfree(p); GDKfree(q); GDKfree(buf)); while (p[pci->retc] < q[pci->retc]) { const char *t; @@ -1073,7 +1074,8 @@ BATXMLconcat(bat *ret, const bat *bid, c q = BUNlast(b); rp = BUNfirst(r); - prepareResult(bn, b, TYPE_xml, "concat", GDKfree(buf)); + prepareResult(bn, b, TYPE_xml, "concat", + GDKfree(buf); BBPunfix(r->batCacheid)); bi = bat_iterator(b); ri = bat_iterator(r); diff --git a/monetdb5/modules/atoms/mtime.c b/monetdb5/modules/atoms/mtime.c --- a/monetdb5/modules/atoms/mtime.c +++ b/monetdb5/modules/atoms/mtime.c @@ -2409,12 +2409,11 @@ MTIMEcompute_rule_foryear(date *ret, con str MTIMEtzone_tostr(str *s, const tzone *ret) { - char buf[128], *s1 = buf; - int len = 128; - - *s1 = 0; + char *s1 = NULL; + int len = 0; + tzone_tostr(&s1, &len, ret); - *s = GDKstrdup(buf); + *s = s1; return MAL_SUCCEED; } diff --git a/monetdb5/modules/kernel/array.c b/monetdb5/modules/kernel/array.c --- a/monetdb5/modules/kernel/array.c +++ b/monetdb5/modules/kernel/array.c @@ -51,7 +51,7 @@ #define get_ptr(b,TYPE) ((TYPE*)(Tloc(b,BUNfirst((b))))) static int -fillgrid_int(BAT **out, int *groups, int *groupsize, int *clustersize, int *offset, int *shift) +fillgrid_int(BAT *out, int *groups, int *groupsize, int *clustersize, int *offset, int *shift) { register int *ptr; int i = *groups; @@ -64,7 +64,7 @@ fillgrid_int(BAT **out, int *groups, int fprintf(stderr, "[grid] (%d,%d,%d,%d)", i, n, r, o); #endif - ptr = get_ptr(*out, int); + ptr = get_ptr(out, int); while (i--) { register int ni = o; @@ -98,17 +98,14 @@ grid_int(BAT **out, int *groups, int *gr fprintf(stderr, "[grid] (%d,%d,%d,%d)", i, n, r, o); #endif - if (out == NULL) { - GDKerror("grid: NULL BAT reference\n"); - return GDK_FAIL; - } + assert(out != NULL); new_bat(*out, (i * (n - o) * r), int); if (*out == NULL) { GDKerror("grid: cannot create the bat (%d BUNs)\n", (i * (n - o) * r)); return GDK_FAIL; } add_vals(*out, (i * (n - o) * r), int); - return fillgrid_int(out, groups, groupsize, clustersize, offset, &s); + return fillgrid_int(*out, groups, groupsize, clustersize, offset, &s); } static int @@ -123,15 +120,16 @@ gridShift_int(BAT **out, int *groups, in fprintf(stderr, "[grid] (%d,%d,%d,%d)", i, n, r, o); #endif + assert(out != NULL); new_bat(*out, (i * (n - o) * r), int); _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list