Err ZDicFontOpen(UInt16 refNum, UInt32 *clientContextP) { ZDicFontGlobalsType *gP; Err err = errNone; Int16 originalOpenCount = 0; /* Error-check our parameters */ ErrFatalDisplayIf( clientContextP == NULL, "null context variable pointer"); /* Initialize return variable */ *clientContextP = 0; /* Get library globals */ gP = PrvLockGlobals(refNum); /* Check if already open */ if (!gP) { /* Allocate and initialize our library globals. */ gP = PrvMakeGlobals(refNum); if ( !gP ) err = memErrNotEnoughSpace; } /* If we have globals, create a client context, increment open * count, and unlock our globals */ if ( gP ) { originalOpenCount = gP->openCount; err = PrvCreateClientContext(gP, clientContextP); if ( !err ) gP->openCount++; PrvUnlockGlobals(gP); /* If there was an error creating a client context and there */ /* are no other clients, free our globals */ if ( err && (originalOpenCount == 0) ) PrvFreeGlobals(refNum); } return( err ); }
Err FlickrOpen(UInt16 refNum) { FlickrGlobals *gP; Err err = errNone; Int16 originalOpenCount = 0; DMSG("FlickrOpen() enter\n"); /* Get library globals */ gP = PrvLockGlobals(refNum); /* Check if already open */ if (!gP) { /* Allocate and initialize our library globals. */ gP = PrvMakeGlobals(refNum); if ( !gP ) err = memErrNotEnoughSpace; } /* If we have globals, create a client context, increment open * count, and unlock our globals */ if ( gP ) { originalOpenCount = gP->openCount; if ( !err ) gP->openCount++; PrvUnlockGlobals(gP); /* If there was an error creating a client context and there */ /* are no other clients, free our globals */ if ( err && (originalOpenCount == 0) ) PrvFreeGlobals(refNum); } DMSG("FlickrOpen() exit\n"); return err; }