On 31-10-2009 09:06:11 +0000, Martin Kersten wrote: [snip]
obj->name= GDKstrdup(name);
what if the GDKstrdup fails here?
obj->sym= newMalBlk(MAXVARS,STMT_INCREMENT); obj->val = newGlobalStack(MAXVARS); + if ( obj->val == NULL) + showException(MAL,"box.new", MAL_MALLOC_FAIL);
I've been looking at mal_sabaoth to deal with GDKmalloc failures, and there is a question to me in cases like this. malloc failed, now the only right way to communicate that to the caller is to throw an exception. However, doing that requires memory too (it GDKmallocs too), so that will most probably fail too. Hence, the throw will die, crash, or even worse, return NULL, which happens to mean MAL_SUCCEED. What should we do here? define a MAL_MALLOC_FAIL constant that we can always return and that's recognised (and hence never freed), or do we redefine MAL_SUCCEED to be non-NULL such that a real NULL means real trouble, and thus an out of memory condition?