From: Rick M. <obj...@gm...> - 2009-08-25 12:42:08
|
One more thing I should add. If an out-of-memory exception does occur, the resulting error is handled using try/catch logic in the interpreter, so you'll not see any allocation failure checks at any of the places that request objects. That's all managed by the syntax handing mechanism, so if a failure does occur, the new call will not return. The propagation of the errors will stop at any active API call stub. Thus in the NewBuffer() API stub: RexxBufferObject RexxEntry NewBuffer(RexxThreadContext *c, size_t l) { ApiContext context(c); try { return (RexxBufferObject)context.ret((RexxObject *)new_buffer(l)); } catch (RexxNativeActivation *) { } return NULLOBJECT; } An out-of-memory error will return to the catch() clause and a NULL value is returned by default. Back in the API code, you'll see a NULL return value and the CheckCondition() API will return true, indicating there is a pending condition active for this context. If you return from your method or routine without calling ClearCondition(), that syntax error will be reraised at that point. Rick On Mon, Aug 24, 2009 at 11:28 PM, Mark Miesfeld<mie...@gm...> wrote: > For this snippet of API code: > > // Set up for the DialogControl CSelf. > RexxBufferObject cdcBuf = c->NewBuffer(sizeof(CDialogControl)); > if ( cdcBuf == NULLOBJECT ) > { > outOfMemoryException(context); > goto done_out; > } > > If the interpreter is out of memory, will it already have raised an > exception if it can't get the memory it needs for the new buffer? In > other words, is my raising an exception redundent and I could just do > this: > > RexxBufferObject cdcBuf = c->NewBuffer(sizeof(CDialogControl)); > if ( cdcBuf == NULLOBJECT ) > { > goto done_out; > } > > Related to this, I tried following the code, but this syntax stumps me: > > inline RexxBuffer *new_buffer(size_t s) { return new (s) RexxBuffer; } > > I don't follow what new (s) RexxBuffer means. The (s) in front of > RexxBuffer throws me. Seems like it should be new RexxBuffer(s) ? > > -- > Mark Miesfeld > > ------------------------------------------------------------------------------ > Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day > trial. Simplify your report design, integration and deployment - and focus on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > Oorexx-devel mailing list > Oor...@li... > https://lists.sourceforge.net/lists/listinfo/oorexx-devel > |