idiom for cleanup + abort

From: Joel Reymont <joelr1_at_gmail.com>
Date: Fri, 30 Jan 2009 22:32:50 +0000

I'm trying to port C code that looks like this

    // This consumes a reference on dictRef.
     kr = IOServiceGetMatchingServices(kIOMasterPortDefault, dictRef,
&iter);
     if (KERN_SUCCESS != kr) {
                fprintf(stderr, "IOServiceGetMatchingServices returned 0x%08x.\n",
kr);
                CFRelease(dictRef);
         return -1;
     }

This is for the Forth side of the Mac driver code for the IntellaSys
FORTHdrive [1] that I'm testing at the moment.

My current Forth code looks like this:

: LOOKUP-BLOCK-STORAGE-NUB ( -- svc | )
    \ IOBlockStorageServices is our child in the I/O registry
    ZSTR "IOBlockStorageServices" IOServiceMatching ( dictRef *)
    ?DUP 0= ABORT" IOServiceMatching did not return a dictionary"
    \ create an iterator over all matching IOService nubs
    kIOMasterPortDefault OVER ITERATOR IOServiceGetMatchingServices
    ABORT" IOServiceGetMatchingServices failed"
    ...

Obviously, this won't work since it will leave the dictRef hanging!
I'd like to create a wrapper around ABORT" but would appreciate advice
(or code!) since the implementation of ABORT" in SwiftForth is a bit
over my head :).

[1] http://is.gd/gQQz

        Thanks in advance, Joel

---
http://tinyco.de
--- Mac & iPhone
----------------------------------------------------------------------
sftalk_at_forth.com      The SwiftForth programming discussion email list
To unsubscribe, send subject "unsubscribe" to sftalk-request_at_forth.com
For list command help, send subject "help" to sftalk-request_at_forth.com
Message archives are located at http://www.forth.com/archive/sftalk
----------------------------------------------------------------------
This list is a forum for SwiftForth users.  For product support and
bug reports, please send email to support_at_forth.com
----------------------------------------------------------------------
Received on Fri Jan 30 2009 - 14:33:18 PST

Subscribe to our e-mail list service. It's free for all SwiftForth and SwiftX users!

This archive was generated 09-Feb-2012. Archive updated nightly.