本文整理汇总了C++中DisposePtr函数的典型用法代码示例。如果您正苦于以下问题:C++ DisposePtr函数的具体用法?C++ DisposePtr怎么用?C++ DisposePtr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DisposePtr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: NewPtrClear
static recDevice *HIDBuildDevice (io_object_t hidDevice)
{
recDevice *pDevice = (recDevice *) NewPtrClear (sizeof (recDevice));
if (pDevice)
{
/* get dictionary for HID properties */
CFMutableDictionaryRef hidProperties = 0;
kern_return_t result = IORegistryEntryCreateCFProperties (hidDevice, &hidProperties, kCFAllocatorDefault, kNilOptions);
if ((result == KERN_SUCCESS) && hidProperties)
{
/* create device interface */
result = HIDCreateOpenDeviceInterface (hidDevice, pDevice);
if (kIOReturnSuccess == result)
{
HIDGetDeviceInfo (hidDevice, hidProperties, pDevice); /* hidDevice used to find parents in registry tree */
HIDGetCollectionElements (hidProperties, pDevice);
}
else
{
DisposePtr((Ptr)pDevice);
pDevice = NULL;
}
CFRelease (hidProperties);
}
else
{
DisposePtr((Ptr)pDevice);
pDevice = NULL;
}
}
return pDevice;
}
示例2: NetDDPCloseSocket
OSErr NetDDPCloseSocket(
short socketNumber)
{
OSErr error= noErr;
if (ddpPacketBuffer)
{
MPPPBPtr myMPPPBPtr= (MPPPBPtr) NewPtrClear(sizeof(MPPParamBlock));
error= MemError();
if (error==noErr)
{
myMPPPBPtr->DDP.socket= socketNumber;
error= PCloseSkt(myMPPPBPtr, FALSE);
DisposePtr((Ptr)ddpPacketBuffer);
ddpPacketBuffer= (DDPPacketBufferPtr) NULL;
DisposePtr((Ptr)myMPPPBPtr);
}
}
return error;
}
示例3: asyncFileClose
int asyncFileClose(AsyncFile *f) {
/* Close the given asynchronous file. */
AsyncFileState *state;
short int volRefNum;
OSErr err;
if (!asyncFileValid(f)) return 0; /* already closed */
state = f->state;
err = GetVRefNum(state->refNum, &volRefNum);
success(err == noErr);
err = FSClose(state->refNum);
success(err == noErr);
if (!interpreterProxy->failed()) err = FlushVol(NULL, volRefNum);
success(err == noErr);
if (asyncFileCompletionProc != nil)
DisposeIOCompletionUPP(asyncFileCompletionProc);
asyncFileCompletionProc = nil;
if (state->bufferPtr != nil) DisposePtr(state->bufferPtr);
DisposePtr((void *) f->state);
f->state = nil;
f->sessionID = 0;
return 0;
}
示例4: SaveDriverState
/*__________________________________________________________________________*/
Boolean SaveDriverState (short refnum, StringPtr file, OSType creator, OSType type)
{
FSSpec spec; OSErr err; TDriverInfos dInfos;
long size, dirID; short vrefNum, ref;
Ptr ptr;
if (FindMidiShareFolder (true, &vrefNum, &dirID) != noErr) return false;
if (!MidiGetDriverInfos (refnum, &dInfos)) return false;
size = Get1DriverStateSize (dInfos.slots);
if (!size) return true;
ptr = NewPtrSys(size);
if (!ptr) return false;
Get1DriverState (refnum, dInfos.slots, ptr, size);
err = FSMakeFSSpec(vrefNum, dirID, file, &spec);
if (err == fnfErr)
err = FSpCreate (&spec, creator, type, smSystemScript);
if (err != noErr) goto err;
err = FSpOpenDF (&spec, fsWrPerm, &ref);
if (err != noErr) goto err;
err = FSWrite (ref, &size, ptr);
FSClose (ref);
DisposePtr (ptr);
return err == noErr;
err:
DisposePtr (ptr);
return false;
}
示例5: RemoveElement
Boolean RemoveElement(LinkedList *listPtr,unsigned long num)
{
ElementHandle moo=listPtr,last=0L;
unsigned long count=0;
while((*moo) && (count!=num))
{
count++;
last=moo;
moo=(ElementHandle)&((**moo).next);
}
if (*moo) // if this is 0L then n wasn't in the list
{
Ptr dataPtr=(**moo).data;
Ptr entityPtr=(Ptr)*moo;
// got it, delete it
if (last==0L) // if last==0L then this was the first element in the list
*listPtr=(ElementPtr)(**moo).next; // the start is the next one (which is null if this was also the last one in the list)
else
(**last).next=(**moo).next; // bypass element moo (element n)
// Free up the ram
DisposePtr(dataPtr);
DisposePtr(entityPtr);
return true; // it's gone
}
else
return false;
}
示例6: PPMADInfoFile
OSErr PPMADInfoFile( char *AlienFile, PPInfoRec *InfoRec)
{
MADSpec *theMAD;
long fileSize;
short fileID;
theMAD = (MADSpec*) NewPtr( sizeof( MADSpec) + 200);
fileID = iFileOpen( AlienFile);
if( !fileID)
{
DisposePtr( (Ptr) theMAD);
return -1;
}
fileSize = iGetEOF( fileID);
iRead( sizeof( MADSpec), (Ptr) theMAD, fileID);
iClose( fileID);
strcpy( InfoRec->internalFileName, theMAD->name);
InfoRec->totalPatterns = theMAD->numPat;
InfoRec->partitionLength = theMAD->numPointers;
InfoRec->totalTracks = theMAD->numChn;
InfoRec->signature = 'MADK';
strcpy( InfoRec->formatDescription, "MADK");
InfoRec->totalInstruments = theMAD->numInstru;
InfoRec->fileSize = fileSize;
DisposePtr( (Ptr) theMAD);
theMAD = NULL;
return noErr;
}
示例7: CleanTemp
void CleanTemp(void)
{
OSErr err = noErr;
short vRefNum;
long dirID;
FSSpec viewerFSp;
XPISpec *xpiList, *currXPI = 0, *nextXPI = 0;
#ifdef MIW_DEBUG
Boolean isDir = false;
#endif
#ifndef MIW_DEBUG
/* get "viewer" in "Temporary Items" folder */
ERR_CHECK(FindFolder(kOnSystemDisk, kTemporaryFolderType, kCreateFolder, &vRefNum, &dirID));
err = FSMakeFSSpec(vRefNum, dirID, kViewerFolder, &viewerFSp);
#else
/* for DEBUG builds temp is "<currProcessVolume>:Temp NSInstall:" */
ERR_CHECK(GetCWD(&dirID, &vRefNum));
err = FSMakeFSSpec(vRefNum, 0, kTempFolder, &viewerFSp);
if (err == fnfErr)
return; /* no debug temp exists */
err = FSpGetDirectoryID(&viewerFSp, &dirID, &isDir);
if (err != noErr || !isDir)
return;
err = FSMakeFSSpec(vRefNum, dirID, kViewerFolder, &viewerFSp);
#endif
/* whack the viewer folder if it exists */
if (err == noErr)
{
ERR_CHECK(DeleteDirectory(viewerFSp.vRefNum, viewerFSp.parID, viewerFSp.name));
}
/* clean out the zippies (.xpi's) */
xpiList = (XPISpec *) NewPtrClear(sizeof(XPISpec));
if (!xpiList)
return;
IterateDirectory(vRefNum, dirID, "\p", 1, CheckIfXPI, (void*)&xpiList);
if (xpiList)
{
currXPI = xpiList;
while(currXPI)
{
nextXPI = currXPI->next; /* save nextXPI before we blow away currXPI */
if (currXPI->FSp)
{
FSpDelete(currXPI->FSp);
DisposePtr((Ptr)currXPI->FSp);
}
DisposePtr((Ptr)currXPI);
currXPI = nextXPI;
}
}
}
示例8: ottcp_free
void ottcp_free(OTTCP *x) {
freeobject(x->o_clock);
freeobject(x->o_connectedclock);
if (x->o_tcp_ep != 0) {
OTCloseProvider(x->o_tcp_ep);
}
DisposePtr(x->o_ReadBufA);
DisposePtr(x->o_ReadBufB);
DisposePtr(x->o_WriteBuf);
}
示例9: SinkerNew
void*
SinkerNew(
SymbolPtr,
short iArgC,
Atom iArgV[])
{
const float kDefVal = 0.0;
short valCount = (iArgC > 0) ? iArgC : 1;
objSinker* me = NIL;
tCurPendPair* vals = (tCurPendPair*) NewPtrClear(valCount * sizeof(tCurPendPair));
tSampleVector* inSigs = (tSampleVector*) NewPtrClear(valCount * sizeof(tSampleVector));
tSampleVector* outSigs = (tSampleVector*) NewPtrClear(valCount * sizeof(tSampleVector));
if (vals == NIL || inSigs == NIL || outSigs == NIL) {
// Quick punt before any damage can be done
if (vals != NIL) DisposePtr((Ptr) vals);
if (inSigs != NIL) DisposePtr((Ptr) inSigs);
if (outSigs != NIL) DisposePtr((Ptr) outSigs);
return NIL;
}
// Let Max/MSP allocate us and inlets
me = (objSinker*) newobject(gObjectClass);
// Add outlets, right to left, and initialize values
if (iArgC == 0) {
// Default to two inlets, one outlet
dsp_setup(&me->coreObject, 2);
outlet_new(me, "signal");
// Don't actually need to initialize as long as kDefVal is zero
// vals[0].current = vals[0].pending = kDefVal;
}
else {
dsp_setup(&me->coreObject, iArgC + 1);
while (--iArgC >= 0) {
outlet_new(me, "signal");
vals[iArgC].current = vals[iArgC].pending = AtomGetFloat(&iArgV[iArgC]);
}
}
// My own initialization. Do this now before we lose the value of iArgCount
me->lastSync = 0.0;
me->valCount = valCount;
me->mode = trigDef;
me->vals = vals;
me->inSigs = inSigs;
me->outSigs = outSigs;
punt:
return me;
}
示例10: TclMacExitHandler
void
TclMacExitHandler()
{
ExitToShellUPPListPtr curProc;
/*
* Loop through all installed Exit handlers
* and call them. Always make sure we are in
* a clean state in case we are recursivly called.
*/
if ((gExitToShellData) != NULL && (gExitToShellData->userProcs != NULL)){
/*
* Call the installed exit to shell routines.
*/
curProc = gExitToShellData->userProcs;
do {
gExitToShellData->userProcs = curProc->nextProc;
CallExitToShellProc(curProc->userProc);
DisposeExitToShellProc(curProc->userProc);
DisposePtr((Ptr) curProc);
curProc = gExitToShellData->userProcs;
} while (curProc != (ExitToShellUPPListPtr) NULL);
}
return;
}
示例11: FadeToColorMultiple
/* Do a gamma fade to the color provided over the time period desired */
OSStatus FadeToColorMultiple( ScreenRef *screens,
unsigned int count,
const RGBColor *color,
float seconds )
{
RLGammaTable *newGammas = (RLGammaTable*) NewPtr( count * sizeof( RLGammaTable ) );
if( NULL == newGammas )
return rlOutOfMemory;
//Generate new gamma tables from the provided color
float red = float( color->red ) / 65535.0;
float green = float( color->green ) / 65535.0;
float blue = float( color->blue ) / 65535.0;
for( int i = 0; i < count; i++ )
{
for( int j = 0; j < kGammaTableEntryCount; j++ )
{
newGammas[i].red[j] = red;
newGammas[i].green[j] = green;
newGammas[i].blue[j] = blue;
}
}
OSStatus err = FadeToGammaMultiple( screens, count, newGammas, seconds );
DisposePtr( (Ptr) newGammas );
return err;
}
示例12: alSourceStop
ALAPI ALvoid ALAPIENTRY alSourceStop (ALuint source)
{
QueueEntry *pQE;
#ifndef MAC_OS_X
smSourceFlushAndQuiet(source);
#endif
gSource[source].state = AL_STOPPED;
gSource[source].readOffset = 0;
if (gSource[source].pCompHdr != NULL) {
#ifdef MAC_OS_X
free(gSource[source].pCompHdr);
#else
DisposePtr(gSource[source].pCompHdr);
#endif
gSource[source].pCompHdr = NULL;
}
gSource[source].uncompressedReadOffset = 0;
#ifdef MAC_OS_X
gSource[source].uncompressedBufferOffset = 0;
#endif
pQE = gSource[source].ptrQueue; // reset all processed flags
while (pQE != NULL)
{
gSource[source].srcBufferNum = 0; // will play the null-buffer, then process queue...
pQE->processed = AL_FALSE;
pQE = pQE->pNext;
}
}
示例13: BigSendAppleEvent
OSErr BigSendAppleEvent(TargetID *targ,AEEventClass aeClass,AEEventID aeID,Ptr *data,short dataLen,DescType dataType,Boolean returnData,Boolean checkForHandlerErr)
{
AEAddressDesc targDesc={typeNull, nil}; // Desc for target
AppleEvent appOut={typeNull, nil},appIn={typeNull, nil};
short sendMode=kAENeverInteract;
OSErr err;
if (returnData || checkForHandlerErr)
sendMode+=kAEWaitReply;
else
sendMode+=kAENoReply;
// Create the address desriptor
err=AECreateDesc(typeTargetID,(Ptr)targ,sizeof(TargetID), &targDesc);
if (err)
return err;
// now create the apple event which will be sent
err=AECreateAppleEvent(aeClass,aeID,&targDesc,kAutoGenerateReturnID,kAnyTransactionID,&appOut);
if (err)
{
AEDisposeDesc(&targDesc);
return err;
}
if (data && *data)
{
err=AEPutParamPtr(&appOut,keyDirectObject,typeChar,*data,dataLen);
DisposePtr(*data);
*data=0L;
if (err)
{
AEDisposeDesc(&appOut);
AEDisposeDesc(&targDesc);
}
}
// Send the apple event
err=AESend(&appOut,&appIn,sendMode,kAENormalPriority,kAEDefaultTimeout,0L,0L);
if (err)
{
AEDisposeDesc(&appOut); // get rid of the apple events
AEDisposeDesc(&appIn);
AEDisposeDesc(&targDesc); // and the address descriptor
}
if (returnData) // get info from reply event
err=FetchParamAnySize(keyDirectObject,&appIn,data,dataType);
// Get the error returned if any
if (!err && checkForHandlerErr)
err=FetchAEErr(&appIn);
// The apple event has been sent, dispose of descriptors
AEDisposeDesc(&appOut); // get rid of the apple events
AEDisposeDesc(&appIn);
AEDisposeDesc(&targDesc); // and the address descriptor
return err;
}
示例14: NetDDPDisposeFrame
void NetDDPDisposeFrame(
DDPFramePtr frame)
{
DisposePtr((Ptr)frame);
return;
}
示例15: SetControlData
/* KillPopMenus(theDialog)
Call when exiting the dialog, before calling DisposeXOPDialog.
The menu handles associated with popup controls are automatically deleted
by the controls because we use SetControlData(...kControlPopupButtonOwnedMenuRefTag...).
However, we need to do some bookkeeping here to keep track of which menu IDs are
free for use in popup menus. This bookkeeping is complicated by the possibility
of subdialogs.
Thread Safety: KillPopMenus is not thread-safe.
*/
void
KillPopMenus(DialogPtr theDialog)
{
int i;
if (gPopMenuInfoP == NULL)
return; // Would happen if you did not create any popup menus.
// Mark menu IDs used for this dialog as free so they can be reused for another dialog.
for(i=0; i<MAX_POPUP_MENUS; i++) {
if (gPopMenuInfoP[i].theDialog == theDialog) { // This is the dialog for which the menu was created?
gPopMenuInfoP[i].theDialog = NULL;
gPopMenuInfoP[i].menuID = 0;
}
}
/* Now see if gPopMenuInfoP is no longer needed. If we just disposed a subdialog,
it is still needed for the parent dialog.
*/
{
int infoStillNeeded;
infoStillNeeded = 0;
for(i=0; i<MAX_POPUP_MENUS; i++) {
if (gPopMenuInfoP[i].menuID != 0) {
infoStillNeeded = 1;
break;
}
}
if (!infoStillNeeded) {
DisposePtr((Ptr)gPopMenuInfoP);
gPopMenuInfoP = NULL;
}
}
}