void * _TIFFrealloc(void* p, size_t s) { Ptr n = p; SetPtrSize(p, s); if (MemError() && (n = NewPtr(s)) != NULL) { BlockMove(p, n, GetPtrSize(p)); DisposePtr(p); } return (n); }
tdata_t _TIFFrealloc(tdata_t p, tsize_t s) { Ptr n = p; SetPtrSize(p, (size_t) s); if (MemError() && (n = NewPtr((size_t) s)) != NULL) { BlockMove(p, n, GetPtrSize(p)); DisposePtr(p); } return ((tdata_t) n); }
Handle QTDR_MakeHandleDataRef (Handle theHandle) { Handle myDataRef = NULL; myDataRef = NewHandleClear(sizeof(Handle)); if (myDataRef != NULL) BlockMove(&theHandle, *myDataRef, sizeof(Handle)); // the following single line can replace the preceding three lines // PtrToHand(&theHandle, &myDataRef, sizeof(Handle)); return(myDataRef); }
static Handle handle_from_c_string (char *str) { int len; Handle retval; len = strlen (str); retval = NewHandle (len); BlockMove (str, *retval, len); return retval; }
void Widget::keyPressEvent(QKeyEvent *event) { switch(event->key()) { case Qt::Key_Up: BlockMove(UP); break; case Qt::Key_Down: BlockMove(DOWN); break; case Qt::Key_Left: BlockMove(LEFT); break; case Qt::Key_Right: BlockMove(RIGHT); break; case Qt::Key_Space: BlockMove(SPACE); break; default: break; } }
static Ptr CopyGammaTable (GammaTblPtr pTableGammaIn) { GammaTblPtr pTableGammaOut = NULL; short tableSize, dataWidth; if (pTableGammaIn) /* if there is a table to copy */ { dataWidth = (pTableGammaIn->gDataWidth + 7) / 8; /* number of bytes per entry */ tableSize = sizeof (GammaTbl) + pTableGammaIn->gFormulaSize + (pTableGammaIn->gChanCnt * pTableGammaIn->gDataCnt * dataWidth); pTableGammaOut = (GammaTblPtr) NewPtr (tableSize); /* allocate new table */ if (pTableGammaOut) BlockMove( (Ptr)pTableGammaIn, (Ptr)pTableGammaOut, tableSize); /* move everything */ } return (Ptr)pTableGammaOut; /* return whatever we allocated, could be NULL */ }
static Ptr CopyGammaTable (GammaTblPtr pTableGammaIn) { GammaTblPtr pTableGammaOut = NULL; short tableSize, dataWidth; if (pTableGammaIn) { dataWidth = (pTableGammaIn->gDataWidth + 7) / 8; tableSize = sizeof (GammaTbl) + pTableGammaIn->gFormulaSize + (pTableGammaIn->gChanCnt * pTableGammaIn->gDataCnt * dataWidth); pTableGammaOut = (GammaTblPtr) NewPtr (tableSize); if (pTableGammaOut) BlockMove( (Ptr)pTableGammaIn, (Ptr)pTableGammaOut, tableSize); } return (Ptr)pTableGammaOut; }
Handle QTDR_MakeURLDataRef (char *theURL) { Handle myDataRef = NULL; Size mySize = 0; // get the size of the URL, plus the terminating null byte mySize = (Size)strlen(theURL) + 1; if (mySize == 1) goto bail; // allocate a new handle and copy the URL into the handle myDataRef = NewHandleClear(mySize); if (myDataRef != NULL) BlockMove(theURL, *myDataRef, mySize); bail: return(myDataRef); }
BOOLEAN NDAAction(EventRecord *sysEvent, int code) { int event; static EventRecord localEvent; unsigned int eventCode; BOOLEAN result = FALSE; switch (code) { case runAction: return result; case eventAction: BlockMove((Pointer)sysEvent, (Pointer)&localEvent, 16); localEvent.wmTaskMask = 0x001FFFFF; eventCode = TaskMasterDA(0, &localEvent); switch(eventCode) { case updateEvt: BeginUpdate(gCalcWinPtr); DrawContents(); EndUpdate(gCalcWinPtr); break; case wInControl: HandleControl(&localEvent); break; case keyDownEvt: case autoKeyEvt: HandleKey(&localEvent); break; } break; case cutAction: case copyAction: case pasteAction: case clearAction: result = TRUE; HandleMenu(code); break; } return result; }
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ // ¥ Initialise // ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ void CMikModDriver::Initialise() { MikMod_RegisterAllDrivers(); MikMod_RegisterAllLoaders(); if (MikMod_Init("")) { unsigned char errstr[256]; char *err=MikMod_strerror(MikMod_errno); errstr[0]=std::strlen(err); BlockMove(err,&errstr[1],errstr[0]); ThrowStr_(-1,errstr); } sInited=true; }
void *pgp_realloc(void *orig, long newLen) { #ifdef PGP_MACINTOSH Ptr newSpace; long oldLen; if(orig) SetPtrSize((Ptr)orig, newLen); else orig=NewPtr(newLen); if(MemError()) { if((newSpace = NewPtr(newLen)) != NULL) { oldLen=GetPtrSize((Ptr)orig); BlockMove(orig, newSpace, oldLen); DisposePtr((Ptr)orig); orig=newSpace; } else orig = NIL; } return orig; #elif PGP_WIN32 void *ptr = NULL; #ifdef _DEBUG if (!HeapValidate(heapID, 0, NULL)) DebugLog("validation failed before reallocating %d bytes at %p", newLen, ptr); #endif // _DEBUG ptr = HeapReAlloc(heapID, HEAP_GENERATE_EXCEPTIONS|HEAP_ZERO_MEMORY, ptr, newLen); #ifdef _DEBUG if (!HeapValidate(heapID, 0, NULL)) DebugLog("validation failed after reallocating %d bytes at %p", newLen, ptr); #endif // _DEBUG return ptr; #endif // PGP_WIN32 }
Size DumpLinkedList(LinkedList *theList,unsigned char *destPtr,Size bufferSize) { ElementHandle moo=theList; // the address of a linked list Size copiedSize=0L,elementSize; while (*moo) { elementSize=GetPtrSize((**moo).data); if (elementSize>(bufferSize-copiedSize)) // too big!, time to go return copiedSize; BlockMove((**moo).data,destPtr,elementSize); destPtr+=elementSize; copiedSize+=elementSize; // get next element moo=(ElementHandle)&((**moo).next); } return copiedSize; }
char *QTDR_GetURLBasename (char *theURL) { char *myBasename = NULL; short myLength = 0; short myIndex; // make sure we got a URL passed in if (theURL == NULL) goto bail; // get the length of the URL myLength = strlen(theURL); // find the position of the rightmost URL separator in theURL if (strchr(theURL, kURLSeparator) != NULL) { myIndex = myLength - 1; while (theURL[myIndex] != kURLSeparator) myIndex--; // calculate the length of the basename myLength = myLength - myIndex - 1; } else { // there is no rightmost URL separator in theURL; // set myIndex so that myIndex + 1 == 0, for the call to BlockMove below myIndex = -1; } // allocate space to hold the string that we return to the caller myBasename = malloc(myLength + 1); if (myBasename == NULL) goto bail; // copy into myBasename the substring of theURL from myIndex + 1 to the end BlockMove(&theURL[myIndex + 1], myBasename, myLength); myBasename[myLength] = '\0'; bail: return(myBasename); }
Boolean FGLstepper::nextEdge(void){ Ptr packetDEREF=v&packetRef; Ptr DEREF=v->xCheckPtr(edgeRef); // this is a counter inside packetRef DEREF=&DEREF[sizeof(GLref)]; // advance to next entry if(edgeSign<0)++edgeIndex; edgeSign=-edgeSign; ++count; Boolean seeking=TRUE; while(seeking){ while(seeking && count<orientedEdgesNo){ BlockMove(DEREF,(Ptr)&refDatum,sizeof(GLref)); if(!(seeking=isNull(refDatum))){ edgeRef.index=packetRef.index; edgeRef.offset=packetRef.offset +edgeRefOffset+count*sizeof(GLref); v->e=edgeIndex*edgeSign; } else { DEREF=&DEREF[sizeof(GLref)]; // advance to next entry if(edgeSign<0)++edgeIndex; edgeSign=-edgeSign; ++count; } } if(seeking){ GLref oldPacket=packetRef; v->xGetPacketNext(packetRef,packetDEREF); v-oldPacket; if(isNull(packetRef)){ // all edges in link have been return(FALSE); // processed } DEREF=packetDEREF=v&packetRef; // restart for search DEREF=&DEREF[edgeRefOffset]; // of next packet edgeIndex=1; edgeSign=1; count=0; } } v-packetRef; return(TRUE); // an edge has been found }
static pascal OSErr setmessageverb (const AppleEvent *event, AppleEvent *reply, long refcon) { #pragma unused (refcon) OSErr ec; AEDesc result; Str255 s; Handle htext; long lentext; Boolean fl; ec = AEGetParamDesc (event, keyDirectObject, typeChar, &result); if (ec != noErr) return (ec); htext = result.dataHandle; if (htext == nil) return (noErr); lentext = GetHandleSize (htext); if (lentext > 255) lentext = 255; s [0] = (unsigned char) lentext; BlockMove (*htext, &s [1], lentext); AEDisposeDesc (&result); setwindowmessage (s); fl = true; ec = AEPutParamPtr (reply, keyDirectObject, typeBoolean, (Ptr) &fl, sizeof (Boolean)); return (ec); } /*setmessageverb*/
void FGLvar::Append(GLref& lastPacket,const GLref& midpoint,const GLref& vRef){ // updates lastPacket Ptr DEREF; GLref ref; // redirect the ideal edges of vRef to midpoint DEREF=this&vRef; xGetPacketRef(ref,GLir,DEREF); if(!isNull(ref)){ cv=vRef; bv=midpoint; xIdentify(GLir); } // get real packet of vRef, cut link, and pack xGetPacketRef(ref,GLr,DEREF); xPutPacketRef(GLr,DEREF,FGLink::NA); this-vRef; bv=vRef; Pack(); // rewind to first packet and link to last packet of midpoint xsetToFirstPacket(ref,ref); DEREF=this&ref; xPutPacketPrev(DEREF,lastPacket); this-ref; DEREF=this&lastPacket; xPutPacketNext(DEREF,ref); this-lastPacket; // redirect all owner packet locations to midpoint, update lastPacket while(!isNull(ref)){ DEREF=this&ref; BlockMove((Ptr)&midpoint,&DEREF[ownerOffset[GLr]],sizeof(GLref)); lastPacket=ref; xGetPacketNext(ref,DEREF); this-lastPacket; } }
void QTFrame_GetDisplayName (char *thePathName, char *theDispName) { SHFILEINFO myFileInfo; DWORD myResult; myResult = SHGetFileInfo(thePathName, (DWORD)0, &myFileInfo, sizeof(myFileInfo), SHGFI_DISPLAYNAME); if (myResult != 0) { // SHGetFileInfo successful strcpy(theDispName, myFileInfo.szDisplayName); } else { // SHGetFileInfo not successful, so find the basename ourselves short myLength = 0; short myIndex; // get the length of the pathname myLength = strlen(thePathName); // find the position of the rightmost path separator in thePathName if (strchr(thePathName, kWinFilePathSeparator) != NULL) { myIndex = myLength - 1; while (thePathName[myIndex] != kWinFilePathSeparator) myIndex--; // calculate the length of the basename myLength = myLength - myIndex - 1; } else { // there is no rightmost path separator in thePathName; // set myIndex so that myIndex + 1 == 0, for the call to BlockMove below myIndex = -1; } // copy into theDispName the substring of thePathName from myIndex + 1 to the end BlockMove(&thePathName[myIndex + 1], theDispName, myLength); theDispName[myLength] = '\0'; } }
void do_about_box( void) { GrafPtr oldPort; DialogPtr dptr; short item, itemType; Handle itemHdl; Rect itemRect; dptr = GetNewDialog( rAboutBox, nil, (WindowPtr)-1L); if( dptr == (DialogPtr)0){ Handle items = NewHandle( sizeof(missing_DITL)); static Rect bounds = {40, 20, 150, 340}; if( ! items) return; BlockMove( missing_DITL, *items, sizeof(missing_DITL)); dptr = NewColorDialog( nil, &bounds, (unsigned char*)"\005About", false, dBoxProc, (WindowPtr)-1L, false, 0, items); } if( dptr == (DialogPtr)0) return; GetPort (&oldPort); SetPort (GetDialogPort(dptr)); GetDialogItem( dptr, ok, &itemType, &itemHdl, &itemRect); InsetRect( &itemRect, -4, -4); SetDialogItem( dptr, 6, userItem + itemDisable, (Handle)outline_hook_upp, &itemRect); FlushEvents( everyEvent, 0); ShowWindow( GetDialogWindow(dptr)); do { ModalDialog( about_filter_upp, &item); } while( item != ok); DisposeDialog( dptr); SetPort( oldPort); }
void getnameandfromdirid (Str255 * sp, LONGINT * fromdirid) { CInfoPBRec cpb; if (globalreply.fName[0] == 0) { cpb.hFileInfo.ioFDirIndex = -1; cpb.hFileInfo.ioDirID = globalreply.fType; cpb.hFileInfo.ioVRefNum = -SFSaveDisk; cpb.hFileInfo.ioNamePtr = *sp; PBGetCatInfo (&cpb, false); if (sp[0] != 0) *fromdirid = cpb.hFileInfo.ioFlParID; else *fromdirid = CurDirStore; } else { *fromdirid = CurDirStore; BlockMove (globalreply.fName, *sp, globalreply.fName[0] + 1); } }
/*e*/ TClut &TClut::operator=(const TClut ©Me) { if (copyMe.ctab) { Size size=GetHandleSize((Handle)copyMe.ctab); if (ctab) BetterSetHandleSize((Handle)ctab,size,0); else { ctab=(CTabHandle)NewHandle(size); ThrowIfMemFull_(ctab); } BlockMove(*copyMe.ctab,*ctab,size); } else { if (ctab) DisposeHandle((Handle)ctab); ctab=0L; } return *this; }
Boolean FrTreeNode::processVertex(){ // if ZBlocal is less than the number of generators, then we // generate edges. Otherwise we go to the next vertex on the stack GLref ref; childVertices->Pop(ref); v->bv=ref; if(isNull(v->bv)){ return finish(); } Ptr DEREF=v&v->bv; v->xPutID(DEREF,IDslot,IDadult); DEREF=&DEREF[((FrTree*)v)->byOffset]; long ZBlocal; BlockMove(DEREF,(Ptr)&ZBlocal,sizeof(long)); if(ZBlocal<((FrTree*)v)->numItems){ entryPoint=firstEdge; } else entryPoint=nextVertex; v-v->bv; return(TRUE); }
// moo is the element to insert the data after Boolean BetterAddElement(Ptr dataPtr,Size dataSize,ElementHandle moo) { // Moo now points to a Ptr to store the next element in. The Ptr is the address of the 'next' // field of the last element in the list. // Add a new ListElement to the list *moo=(ElementPtr)NewPtr(sizeof(ListElement)); if (!*moo) // failed? return false; (*moo)->next=0L; (*moo)->data=0L; // Add the data to that element (*moo)->data=NewPtr(dataSize); if (!(*moo)->data) // failed? { DisposePtr((Ptr)*moo); *moo=0L; return false; } BlockMove(dataPtr,(*moo)->data,dataSize); return true; }
Ptr GetChoosePasswordDispatchPtr( void ) { long size; Ptr data; long srcFunction; srcFunction = (*(long *) ((Ptr) ChoosePasswordDispatch + 2)); size = (*(long *) ((Ptr) GetChoosePasswordDispatchPtr + 2)) - srcFunction; data = NewMemory ( kTemp, size ); ASSERT_MESG( data, "Cannot allocate memory for choose icon proc" ); if ( data ) { #ifdef SIMULATOR *(short *)data = kJmpLongOpcode; *(long *)((long)data+2) = (long) ChoosePasswordDispatch; #else CheckCodeForJTRefs((void *)ChoosePasswordDispatch, size); BlockMove ( (Ptr) srcFunction, data, size ); #endif } return data; }
/* can be called at interrupt time */ void queue_network_speaker_data( byte *buffer, short count) { if (speaker) { switch (speaker->state) { case _speaker_is_off: /* we were off but now weÕre getting data; fill one double buffer with static and change our state to _turning_on (weÕll wait until we receive another full double buffer worth of data before beginning to replay) */ // ZZZ: CarbonSndPlayDB emulation layer specifically warns against calling // SndDoImmediate() with a quietCmd at interrupt time - which is what // quiet_network_speaker() would do. So instead here we try resetting // the speaker (which ought to be safe I think) now, but delay issuing the // quiet commands until just before we start playing again. #if defined(TARGET_API_MAC_CARBON) reset_network_speaker(); #else quiet_network_speaker(); /* we could be playing trailing static */ #endif speaker->state= _speaker_is_turning_on; fill_network_speaker_buffer(speaker->header->dbhBufferPtr[0]); break; case _speaker_is_on: case _speaker_is_turning_on: speaker->connection_status= 0; break; default: vhalt(csprintf(temporary, "what the hell is #%d!?", speaker->state)); } /* move incoming data into queue, NULL buffer means static */ if (speaker->queue_size+count<=MAXIMUM_QUEUE_SIZE) { if (buffer) { BlockMove(buffer, speaker->queue+speaker->queue_size, count); } else { fill_buffer_with_static((byte *)speaker->queue+speaker->queue_size, count); } speaker->queue_size+= count; } else { // This really shouldn't log in the non-main thread yet... logAnomaly3("queue_net_speaker_data() is ignoring data: #%d+#%d>#%d", speaker->queue_size, count, MAXIMUM_QUEUE_SIZE); } #ifdef SNDPLAYDOUBLEBUFFER_DOESNT_SUCK switch (speaker->state) { case _speaker_is_turning_on: /* check and see if we have enough data to turn on */ if (speaker->queue_size>=speaker->block_size) { OSErr error; error= SndPlayDoubleBuffer(speaker->channel, speaker->header); vwarn(error==noErr, csprintf(temporary, "SndPlayDoubleBuffer(%p,%p)==#%d", speaker->channel, speaker->header, error)); speaker->state= _speaker_is_on; } break; } #endif } }
bool wxSound::DoPlay(unsigned flags) const { Stop(); Movie movie; switch(m_type) { case wxSound_MEMORY: { if (!wxInitQT()) return false; Handle myHandle, dataRef = nil; MovieImportComponent miComponent; Track targetTrack = nil; TimeValue addedDuration = 0; long outFlags = 0; OSErr err; ComponentResult result; myHandle = NewHandleClear((Size)m_waveLength); BlockMove(m_hSnd, *myHandle, m_waveLength); err = PtrToHand(&myHandle, &dataRef, sizeof(Handle)); if (memcmp(&m_hSnd[8], "WAVE", 4) == 0) miComponent = OpenDefaultComponent(MovieImportType, kQTFileTypeWave); else if (memcmp(&m_hSnd[8], "AIFF", 4) == 0) miComponent = OpenDefaultComponent(MovieImportType, kQTFileTypeAIFF); else if (memcmp(&m_hSnd[8], "AIFC", 4) == 0) miComponent = OpenDefaultComponent(MovieImportType, kQTFileTypeAIFC); else { wxLogSysError(wxT("wxSound - Location in memory does not contain valid data")); return false; } movie = NewMovie(0); result = MovieImportDataRef(miComponent, dataRef, HandleDataHandlerSubType, movie, nil, &targetTrack, nil, &addedDuration, movieImportCreateTrack, &outFlags); if (result != noErr) { wxLogSysError(wxString::Format(wxT("Couldn't import movie data\nError:%i"), (int)result)); } SetMovieVolume(movie, kFullVolume); GoToBeginningOfMovie(movie); DisposeHandle(myHandle); } break; case wxSound_RESOURCE: { SoundComponentData data; unsigned long numframes, offset; ParseSndHeader((SndListHandle)m_hSnd, &data, &numframes, &offset); //m_waveLength = numFrames * data.numChannels; SndChannelPtr pSndChannel; SndNewChannel(&pSndChannel, sampledSynth, initNoInterp + (data.numChannels == 1 ? initMono : initStereo), NULL); if(SndPlay(pSndChannel, (SndListHandle) m_hSnd, flags & wxSOUND_ASYNC ? 1 : 0) != noErr) return false; if (flags & wxSOUND_ASYNC) { lastSoundTimer = ((wxSMTimer*&)m_pTimer) = new wxSMTimer(pSndChannel, m_hSnd, flags & wxSOUND_LOOP ? 1 : 0, &lastSoundIsPlaying); lastSoundIsPlaying = true; ((wxTimer*)m_pTimer)->Start(MOVIE_DELAY, wxTIMER_CONTINUOUS); } else SndDisposeChannel(pSndChannel, TRUE); return true; } break; case wxSound_FILE: { if (!wxInitQT()) return false; OSErr err = noErr ; Handle dataRef = NULL; OSType dataRefType; err = QTNewDataReferenceFromFullPathCFString(wxMacCFStringHolder(m_sndname,wxLocale::GetSystemEncoding()), (UInt32)kQTNativeDefaultPathStyle, 0, &dataRef, &dataRefType); wxASSERT(err == noErr); if (NULL != dataRef || err != noErr) { err = NewMovieFromDataRef( &movie, newMovieDontAskUnresolvedDataRefs , NULL, dataRef, dataRefType ); wxASSERT(err == noErr); DisposeHandle(dataRef); } if (err != noErr) { wxLogSysError( wxString::Format(wxT("wxSound - Could not open file: %s\nError:%i"), m_sndname.c_str(), err ) ); return false; } } break; default: return false; }//end switch(m_type) //Start the movie! StartMovie(movie); if (flags & wxSOUND_ASYNC) { //Start timer and play movie asyncronously lastSoundTimer = ((wxQTTimer*&)m_pTimer) = new wxQTTimer(movie, flags & wxSOUND_LOOP ? 1 : 0, &lastSoundIsPlaying); lastSoundIsPlaying = true; ((wxQTTimer*)m_pTimer)->Start(MOVIE_DELAY, wxTIMER_CONTINUOUS); } else { wxASSERT_MSG(!(flags & wxSOUND_LOOP), wxT("Can't loop and play syncronously at the same time")); //Play movie until it ends, then exit //Note that due to quicktime caching this may not always //work 100% correctly while (!IsMovieDone(movie)) MoviesTask(movie, 1); DisposeMovie(movie); } return true; }
t_int *stft_perform(t_int *w) { t_stft *x = (t_stft *)(w[1]); float *inreal = (float *)(w[2]); float *outreal = (float *)(w[3]); int n = w[4]; int i, m, np, count; long pts = x->x_fftsize; long hop = x->x_hop; float *b; float *ei = x->x_in + pts; // indicates end pointer of buffer float *eo = x->x_out + pts; //float mult = x->x_1overpts; float *wind = x->x_window; if (x->x_obj.z_disabled) goto exit; if (n > pts) { // if sigvect > fftsize np = pts; count = n / pts; } else { np = n; count = 1; } m = np; set_zero(outreal, n); while (count--) { // do big loop just once if sigvect < fftsize b = x->x_inptr; // copy signal into input buffer BlockMove(inreal,b, np * sizeof(float)); b += np; // increment temp input pointer by sigvs // we will increment input pointer later if (b == ei) { // if temp input pointer is at end float *real = x->x_out; float *freal = x->x_out; t_complex *frame = x->x_sdifbuf; long wpts = pts; long fpts = x->x_sdifbufsize -1; // copy input buffer into oputput buffer and fft the outbuffer BlockMove(x->x_in,x->x_out,pts * sizeof(float)); while (wpts--) *real++ *= *wind++; // do windowing realfft(pts, x->x_out); // perform mayer FFT //fftRealfast(pts, x->x_out, x->x_twiddle); // REALFAST FFT *outreal = 1.0; //send just a click out // fill sdifbuf for (i=1; i< fpts; i++) { x->x_sdifbuf[i].re = x->x_out[i]; x->x_sdifbuf[i].im = x->x_out[i+fpts]; } x->x_sdifbuf[0].re = x->x_out[0]; x->x_sdifbuf[fpts].re = x->x_out[fpts]; x->x_sdifbuf[0].im = x->x_sdifbuf[fpts].im = 0.; // shift and reset i/o buffer pointers BlockMove(x->x_in+hop,x->x_in,(pts-hop) * sizeof(float)); x->x_inptr = x->x_in +pts-hop; } else if (b) { // otherwise just increment input pointer x->x_inptr += np; } } exit: return (w + 5); }
FTT1pSubnode::FTT1pSubnode(FGLnode *aSupervisor,FTTpres *currentPres, long distinguishedRel,long timeRemaining) :FGLnode(aSupervisor){ this->currentPres=currentPres; this->distinguishedRel=distinguishedRel; this->timeRemaining=timeRemaining; // zero the member objects for proper destruction in case // of initialization failure newPres=ZERO; newPresDispose=FALSE; wordsToGLvar=ZERO; fold=ZERO; reducedFold=ZERO; grow=ZERO; CcloneGen=ZERO; presGen=ZERO; renumber=ZERO; itsGLink=ZERO; Cayley=ZERO; CayleyClone=ZERO; // the requirement that presentations locally number the free // generators from g->numItems+1 to globalSymbols->numItems // means that we don't need to search words whose generators // are in this range. Obviously no reduced word containing a // free generator can be a consequence. lettersNo=currentPres->g->numItems; if(!lettersNo){ xErr(59); } // control relatorIsConsequence=FALSE; wordsNo=0; verticesNo=-1; edgesNo=-1; foldEntryLocation=FGLink::NA; // construct Cayley, CayleyClone and their GLink itsGLink=new FGLink; // Cayley FGLvarInitInfo* info= new FCayleyInitInfo; info->rNoEntries=lettersNo; info->iNoEntries=1; Cayley= new FCayley(this,itsGLink,(FCayleyInitInfo*)info); // CayleyClone CayleyClone=new FGLvar(itsGLink,info); Str255 str; sprintf((char*)str,"CayleyClone"); CtoPstr((char*)str); BlockMove((Ptr)str,(Ptr)CayleyClone->itsName,12); delete info;info=0; // startup function mailPerson=wordsToGLvarMail; func=TT1pSubfunc; // control reentryFunc=ZERO; }
void FGLvar::V(void){ // creates real vertex, stores location in cv // links bv to cv with edge index e // distinguishes the new edge entry in the // bv and cv edge look-up tables // make sure base is OK if(isNull(bv)){ varErr(32); } // get space GLref ref; newPacket(ref,GLrv); // set cv cv=ref; // initialize the real vertex Ptr DEREF=this&cv; xPutPacketisGarbage(DEREF,TRUE); xPutPacketisIdeal(DEREF,FALSE); GLref NA=FGLink::NA; xPutPacketRef(GLir,DEREF,NA); xPutPacketRef(GLr,DEREF,NA); DEREF=&DEREF[2*sizeof(Boolean)+2*sizeof(GLref)]; xUnsignedLongZeroInit(DEREF, IDactiveMax); this-cv; // set up base as initial vertex DEREF=this&bv; Boolean isbvIdeal=xGetPacketisIdeal(DEREF); GLflag bflag; if(isbvIdeal){ bflag=GLi; //an ideal vertex always uses the ideal link } else { bflag=GLr; //two real vertices use the real link } // set up info for packetWrite. The refDatum is garbage for this write // because we don't know what to put here yet writePacketInfo info; info.flag=bflag; info.request=GLunusedOrNew; info.index=e; info.refDatum=bv; // this is a "fake" value. Any valid non null // address would do info.ownerVertexRef=bv; xGetPacketRef(info.entryPacketRef,bflag,DEREF); packetWrite(&info); GLref bpacketRef=info.exitPacketRef; long boffset=info.offset; xPutPacketRef(bflag,DEREF,bpacketRef); this-bv; /*set up companion as terminal vertex*/ GLflag cflag=bflag; if(bflag==GLi) cflag=GLir; //a real vertex connected to an ideal vertex //uses the ideal link of a real vertex // set up info for packetWrite DEREF=this&cv; info.flag=cflag; info.request=GLunusedOrNew; info.index= -e; xPacketRefToOwnerRef(info.refDatum,bflag,bpacketRef); info.ownerVertexRef=cv; xGetPacketRef(info.entryPacketRef,cflag,DEREF); packetWrite(&info); GLref cpacketRef=info.exitPacketRef; xPutPacketRef(cflag,DEREF,cpacketRef); // now we can set the datum in the base vertex packet GLref bDatum; xPacketRefToOwnerRef(bDatum,cflag,cpacketRef); this-cv; DEREF=this&bpacketRef; BlockMove((Ptr)&bDatum,&DEREF[boffset],sizeof(GLref)); this-bpacketRef; }
void *memcpy(const void *dest, const void *source, long n) { BlockMove((void *)source,(void *)dest,n); return 0; }
int __cdecl _heap_grow ( REG1 size_t size ) { REG2 int index; struct _heap_region_ *pHeapRegions; int free_entry = -1; size_t sizeTmp; Handle hTemp; /* * Bump size to include header and round to nearest page boundary. */ size += _HDRSIZE; size = _ROUND2(size, _GRANULARITY); /* * Loop through the region table looking for an existing region * we can grow. Remember the index of the first null region entry. * * size = size of grow request */ for ( index=index_start ; index < _heap_region_table_cur; index++ ) { pHeapRegions = (struct _heap_region_ *)(*hHeapRegions); /* * Grow this region to satisfy the request. */ if ( (pHeapRegions+index)->_regbase != NULL) { if (_heap_grow_region(index, size) != -1) { index_start = index; return 0; } } pHeapRegions = (struct _heap_region_ *)(*hHeapRegions); if ( (free_entry == -1) && ((pHeapRegions+index)->_regbase == NULL) ) /* * Remember 1st free table entry for later */ { free_entry = index; break; } } /* * Could not find any existing regions to grow. Try to * get a new region. * * size = size of grow request * free_entry = index of first free entry in table */ if ( free_entry == -1) /* * No free table entries: grow heap region table. */ { sizeTmp = sizeof(struct _heap_region_)*(_heap_region_table_cur+_HEAP_REGIONMAX); if (hHeapRegions) { SetHandleSize(hHeapRegions, sizeTmp); } if (hHeapRegions== NULL || *pMemErr != 0) { /* * grow failed */ hTemp = NewHandle(sizeTmp); if (hTemp == NULL) { return (-1); } HLock(hTemp); if (hHeapRegions != NULL) { BlockMove(*hHeapRegions, *hTemp, sizeof(struct _heap_region_)*_heap_region_table_cur); DisposeHandle(hHeapRegions); } hHeapRegions = hTemp; } /* * set rest of the table to zero */ memset(*hHeapRegions + sizeof(struct _heap_region_)*_heap_region_table_cur, 0, sizeof(struct _heap_region_)*_HEAP_REGIONMAX); free_entry = _heap_region_table_cur; _heap_region_table_cur += _HEAP_REGIONMAX; } /* * Get a new region to satisfy the request. */ return( _heap_new_region(free_entry, size) ); }