Changeset: de8154a2b348 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=de8154a2b348 Modified Files: gdk/gdk_system.h monetdb5/mal/mal_dataflow.c monetdb5/mal/mal_listing.c monetdb5/mal/mal_module.c monetdb5/mal/mal_profiler.c monetdb5/modules/atoms/inet.c Branch: Jun2016 Log Message:
Some cleanup after changeset 9b3d30af4f4d. diffs (243 lines): diff --git a/gdk/gdk_system.h b/gdk/gdk_system.h --- a/gdk/gdk_system.h +++ b/gdk/gdk_system.h @@ -228,19 +228,19 @@ gdk_export ATOMIC_TYPE volatile GDKlocks MT_Lock * volatile _p; \ /* save a copy for statistical purposes */ \ _p = GDKmalloc(sizeof(MT_Lock)); \ - if( _p) { \ - memcpy(_p, l, sizeof(MT_Lock)); \ - while (ATOMIC_TAS(GDKlocklistlock, dummy) != 0) \ - ; \ - _p->next = GDKlocklist; \ - GDKlocklist = _p; \ - for (_p = GDKlocklist; _p; _p = _p->next) \ - if (_p->next == (l)) { \ - _p->next = (l)->next; \ - break; \ - } \ - ATOMIC_CLEAR(GDKlocklistlock, dummy); \ - }\ + while (ATOMIC_TAS(GDKlocklistlock, dummy) != 0) \ + ; \ + if( _p) { \ + memcpy(_p, l, sizeof(MT_Lock)); \ + _p->next = GDKlocklist; \ + GDKlocklist = _p; \ + } \ + for (_p = GDKlocklist; _p; _p = _p->next) \ + if (_p->next == (l)) { \ + _p->next = (l)->next; \ + break; \ + } \ + ATOMIC_CLEAR(GDKlocklistlock, dummy); \ } \ } while (0) diff --git a/monetdb5/mal/mal_dataflow.c b/monetdb5/mal/mal_dataflow.c --- a/monetdb5/mal/mal_dataflow.c +++ b/monetdb5/mal/mal_dataflow.c @@ -336,10 +336,9 @@ DFLOWworker(void *T) srand((unsigned int) GDKusec()); #endif GDKsetbuf(GDKmalloc(GDKMAXERRLEN)); /* where to leave errors */ - if( GDKerrbuf == 0){ + if( GDKerrbuf == 0) fprintf(stderr,"DFLOWworker:Could not allocate GDKerrbuf\n"); - GDKsetbuf(0); - } else + else GDKerrbuf[0] = 0; MT_lock_set(&dataflowLock); cntxt = t->cntxt; 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 @@ -46,8 +46,10 @@ renderTerm(MalBlkPtr mb, MalStkPtr stk, int varid = getArg(p,idx); buf = GDKzalloc(maxlen); - if( buf == NULL) - throw(MAL,"renderTerm",MAL_MALLOC_FAIL); + if( buf == NULL) { + GDKerror("renderTerm:Failed to allocate"); + return NULL; + } // show the name when required or is used if ((flg & LIST_MAL_NAME) && !isVarConstant(mb,varid) && !isVarTypedef(mb,varid)) { nme = getVarName(mb,varid); @@ -73,7 +75,7 @@ renderTerm(MalBlkPtr mb, MalStkPtr stk, if( buf == 0){ GDKerror("renderTerm:Failed to allocate"); - return 0; + return NULL; } if( strcmp(cv,"nil") == 0){ strcat(buf+len,cv); @@ -153,10 +155,12 @@ fcnDefinition(MalBlkPtr mb, InstrPtr p, advance(t, base, len); for (i = p->retc; i < p->argc; i++) { - arg = renderTerm(mb, 0, p, i, (LIST_MAL_NAME | LIST_MAL_TYPE | LIST_MAL_PROPS)); - snprintf(t, (len-(t-base)),"%s", arg); + arg = renderTerm(mb, 0, p, i, (LIST_MAL_NAME | LIST_MAL_TYPE | LIST_MAL_PROPS)); + if (arg) { + snprintf(t, (len-(t-base)),"%s", arg); + GDKfree(arg); + } advance(t, base, len); - GDKfree(arg); if( i<p->argc-1) { sprintf(t,","); advance(t,base,len); @@ -182,9 +186,11 @@ fcnDefinition(MalBlkPtr mb, InstrPtr p, t += 3; for (i = 0; i < p->retc; i++) { arg = renderTerm(mb, 0, p, i, (LIST_MAL_NAME | LIST_MAL_TYPE | LIST_MAL_PROPS)); - snprintf(t,(len-(t-base)),"%s", arg); + if (arg) { + snprintf(t,(len-(t-base)),"%s", arg); + GDKfree(arg); + } advance(t,base,len); - GDKfree(arg); if( i<p->retc-1) { sprintf(t,","); advance(t,base,len); @@ -296,8 +302,10 @@ instruction2str(MalBlkPtr mb, MalStkPtr for (i = 0; i < p->retc; i++) { arg= renderTerm(mb, stk, p, i, flg); - snprintf(t,(len-(t-base)), "%s", arg); - GDKfree(arg); + if (arg) { + snprintf(t,(len-(t-base)), "%s", arg); + GDKfree(arg); + } advance(t,base,len); if (i < p->retc - 1) *t++ = ','; @@ -348,8 +356,10 @@ instruction2str(MalBlkPtr mb, MalStkPtr for (i = p->retc; i < p->argc; i++) { arg= renderTerm(mb, stk, p, i, flg); - snprintf(t,(len-(t-base)), "%s", arg); - GDKfree(arg); + if (arg) { + snprintf(t,(len-(t-base)), "%s", arg); + GDKfree(arg); + } advance(t,base,len); if (i < p->argc -1){ 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 @@ -25,8 +25,6 @@ Module scopeJump[256][256]; /* to speed static void newSubScope(Module scope){ scope->subscope = (Symbol *) GDKzalloc(MAXSCOPE * sizeof(Symbol)); - if( scope->subscope == NULL) - GDKerror("newSubScope:"MAL_MALLOC_FAIL); } void @@ -34,7 +32,7 @@ mal_module_reset(void) { freeModuleList(mal_scope); mal_scope = NULL; - memset((char*) scopeJump, 0, 256 * 256); + memset(scopeJump, 0, 256 * 256); } /* * Definition of a new module scope may interfere with concurrent @@ -68,17 +66,18 @@ Module newModule(Module scope, str nme){ assert(nme != NULL); cur = (Module) GDKzalloc(sizeof(ModuleRecord)); if( cur == NULL){ - GDKerror("newModule:"MAL_MALLOC_FAIL); - } else { - cur->name = nme; - cur->outer = NULL; - cur->sibling = NULL; - cur->subscope = NULL; - cur->isAtomModule = FALSE; + return scope; } - if ( cur == NULL) - return scope; + cur->name = nme; + cur->outer = NULL; + cur->sibling = NULL; + cur->subscope = NULL; + cur->isAtomModule = FALSE; newSubScope(cur); + if (cur->subscope == NULL) { + GDKfree(cur); + return NULL; + } if( scope != NULL){ cur->outer = scope->outer; scope->outer= cur; @@ -204,8 +203,11 @@ void insertSymbol(Module scope, Symbol p scope = c; } t = getSubScope(getFunctionId(sig)); - if( scope->subscope == NULL) + if( scope->subscope == NULL) { newSubScope(scope); + if (scope->subscope == NULL) + return; + } if(scope->subscope[t] == prg){ /* already known, last inserted */ } else { diff --git a/monetdb5/mal/mal_profiler.c b/monetdb5/mal/mal_profiler.c --- a/monetdb5/mal/mal_profiler.c +++ b/monetdb5/mal/mal_profiler.c @@ -190,18 +190,20 @@ renderProfilerEvent(MalBlkPtr mb, MalStk /* generate actual call statement */ stmt = instruction2str(mb, stk, pci, LIST_MAL_ALL); - c = stmt; + if (stmt) { + c = stmt; - while (stmt && *c && isspace((int)*c)) - c++; - if( stmt && *c){ - stmtq = mal_quote(c, strlen(c)); - if (stmtq != NULL) { - logadd("\"stmt\":\"%s\",%s", stmtq,prettify); - GDKfree(stmtq); + while (*c && isspace((int)*c)) + c++; + if( *c){ + stmtq = mal_quote(c, strlen(c)); + if (stmtq != NULL) { + logadd("\"stmt\":\"%s\",%s", stmtq,prettify); + GDKfree(stmtq); + } } - } - GDKfree(stmt); + GDKfree(stmt); + } // ship the beautified version as well diff --git a/monetdb5/modules/atoms/inet.c b/monetdb5/modules/atoms/inet.c --- a/monetdb5/modules/atoms/inet.c +++ b/monetdb5/modules/atoms/inet.c @@ -106,8 +106,8 @@ INETfromString(const char *src, int *len GDKfree(*retval); *retval = GDKzalloc(sizeof(inet)); if( *retval == NULL){ - GDKerror("INETfromString "MAL_MALLOC_FAIL); - goto error; + GDKerror("INETfromString "MAL_MALLOC_FAIL); + goto error; } } else { memset(*retval, 0, sizeof(inet)); _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list