예제 #1
0
void
InitOptObject(void)
{
	FSSpec 	tmp;
	OSErr	err=noErr;
	Boolean isDir;
	
	gControls->opt = (Options*)NewPtrClear(sizeof(Options));

	if (!gControls->opt)
	{
        ErrorHandler(eMem, nil);
		return;
	}
	
	/* SetupTypeWin options */
	gControls->opt->instChoice = 1;		
	gControls->opt->folder = (unsigned char *)NewPtrClear(64*sizeof(unsigned char));
	if (!gControls->opt->folder)
	{
        ErrorHandler(eMem, nil);
		return;
	}
	
	/* TerminalWIn options */
	gControls->opt->siteChoice = 1;
	gControls->opt->saveBits = false;
	
	gControls->opt->vRefNum = -1;
	err = FSMakeFSSpec(gControls->opt->vRefNum, 0, "\p", &tmp);
	pstrcpy( gControls->opt->folder, tmp.name );
	err = FSpGetDirectoryID( &tmp, &gControls->opt->dirID, &isDir );

}
예제 #2
0
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;
	}
예제 #3
0
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;
}
예제 #4
0
void PAS_sortTypes(short sourceRefNum, ResType **resTypePtr, long *count)
{
	short				oldRef;
	short				typeIndex;
	short				numberOfTypes;
		
	*count	=	-1;
	
	oldRef = CurResFile();
		
	UseResFile(sourceRefNum);

	numberOfTypes = Count1Types();
	
	*resTypePtr	=	(ResType*) NewPtrClear( numberOfTypes * sizeof(OSType) );
	
	for (typeIndex=1; typeIndex <= numberOfTypes; typeIndex++)
	{
		Get1IndType(&(*resTypePtr)[typeIndex-1], typeIndex);
	}
	
	UseResFile(oldRef);
	
	PAS_bubbleSortResType(*resTypePtr, numberOfTypes);
	
	*count = numberOfTypes;
}	
예제 #5
0
static	void	DisplaySimpleWindow( void )
{
	OSErr					err;
	WindowRef				window;
	WindowStorage			*windowStorage;
	WindowGroupRef			windowGroup;
	static	EventHandlerUPP	simpleWindowEventHandlerUPP;
	const EventTypeSpec	windowEvents[]	=
	    {
			{ kEventClassCommand, kEventCommandProcess },
			{ kEventClassWindow, kEventWindowClickContentRgn },
			{ kEventClassWindow, kEventWindowBoundsChanging },
			{ kEventClassWindow, kEventWindowBoundsChanged },
			{ kEventClassWindow, kEventWindowClose }
		};
	
	err	= CreateWindowFromNib( g.mainNib, CFSTR("MainWindow"), &window );
	if ( (err != noErr) || (window == NULL) )	goto Bail;
	
	if ( simpleWindowEventHandlerUPP == NULL ) simpleWindowEventHandlerUPP	= NewEventHandlerUPP( SimpleWindowEventHandlerProc );
	err	= InstallWindowEventHandler( window, simpleWindowEventHandlerUPP, GetEventTypeCount(windowEvents), windowEvents, window, NULL );

	windowStorage	= (WindowStorage*) NewPtrClear( sizeof(WindowStorage) );
	SetWRefCon( window, (long) windowStorage );

	err	= CreateWindowGroup( kWindowGroupAttrMoveTogether | kWindowGroupAttrLayerTogether | kWindowGroupAttrHideOnCollapse, &windowGroup );
	if ( err == noErr )	err	= SetWindowGroupParent( windowGroup, g.windowGroups[1] );		//	Default group
	if ( err == noErr )	err	= SetWindowGroup( window, windowGroup );

	ShowWindow( window );

Bail:
	return;
}
예제 #6
0
pascal void ModeListIterator(void *userData, DMListIndexType, DMDisplayModeListEntryPtr displaymodeInfo)
{
	unsigned long			depthCount;
	short					iCount;
	ListIteratorDataRec		*myIterateData		= (ListIteratorDataRec*) userData;
	DepthInfo				*myDepthInfo;
	
	// set user data in a round about way
	myIterateData->displayModeTimingInfo		= *displaymodeInfo->displayModeTimingInfo;
	
	// now get the DMDepthInfo info into memory we own
	depthCount = displaymodeInfo->displayModeDepthBlockInfo->depthBlockCount;
	myDepthInfo = (DepthInfo*)NewPtrClear(depthCount * sizeof(DepthInfo));

	// set the info for the caller
	myIterateData->depthBlockCount = depthCount;
	myIterateData->depthBlocks = myDepthInfo;

	// and fill out all the entries
	if (depthCount) for (iCount=0; iCount < depthCount; iCount++)
	{
		myDepthInfo[iCount].depthSwitchInfo = 
			*displaymodeInfo->displayModeDepthBlockInfo->depthVPBlock[iCount].depthSwitchInfo;
		myDepthInfo[iCount].depthVPBlock = 
			*displaymodeInfo->displayModeDepthBlockInfo->depthVPBlock[iCount].depthVPBlock;
	}
}
예제 #7
0
pascal ComponentResult Theora_ImageCodecOpen(Theora_Globals glob, ComponentInstance self)
{
	ComponentResult err;

	glob = (Theora_Globals)NewPtrClear(sizeof(Theora_GlobalsRecord));
        dbg_printf("\n--:Theora:- CodecOpen(%08lx) called\n", (long)glob);
	if (err = MemError()) goto bail;

	SetComponentInstanceStorage(self, (Handle)glob);

	glob->self = self;
	glob->target = self;
	glob->wantedDestinationPixelTypeH = (OSType **)NewHandle(sizeof(OSType) * (kNumPixelFormatsSupported + 1));
	if (err = MemError()) goto bail;
	glob->drawBandUPP = NULL;
        glob->info_initialised = false;
        glob->last_frame = -1;

        glob->p_buffer = NewPtr(kPacketBufferAllocIncrement);
        glob->p_buffer_len = kPacketBufferAllocIncrement;
        glob->p_buffer_used = 0;

        // many of the functions are delegated actually
	err = OpenADefaultComponent(decompressorComponentType, kBaseCodecType, &glob->delegateComponent);
	if (err) goto bail;

	ComponentSetTarget(glob->delegateComponent, self);

bail:
	return err;
}
예제 #8
0
파일: TextSubCodec.c 프로젝트: JanX2/Perian
// Component Open Request - Required
pascal ComponentResult TextSubCodecOpen(TextSubGlobals glob, ComponentInstance self)
{
	ComponentResult err;

	// Allocate memory for our globals, set them up and inform the component manager that we've done so
	glob = (TextSubGlobals)NewPtrClear(sizeof(TextSubGlobalsRecord));
	if (err = MemError()) goto bail;

	SetComponentInstanceStorage(self, (Handle)glob);

	glob->self = self;
	glob->target = self;
	glob->wantedDestinationPixelTypeH = (OSType **)NewHandleClear((kNumPixelFormatsSupportedTextSub+1) * sizeof(OSType));
	if (err = MemError()) goto bail;
	glob->drawBandUPP = NULL;
	glob->ssa = NULL;
	glob->colorSpace = NULL;
	glob->translateSRT = true;
	
	// Open and target an instance of the base decompressor as we delegate
	// most of our calls to the base decompressor instance
	err = OpenADefaultComponent(decompressorComponentType, kBaseCodecType, &glob->delegateComponent);
	if (err) goto bail;

	ComponentSetTarget(glob->delegateComponent, self);

bail:
	return err;
}
예제 #9
0
unsigned atalk_ddp_open(DDPAddress* ip_dst, unsigned char flags, unsigned *local_port ) {
	unsigned long		i;
					 
	//	save all of the paramaters in our array and return the index
	//	that we just used
	
	if (gDests == nil) {
		gDests = (DestStruct*) NewPtrClear(sizeof(DestStruct) * MAX_DESTS);		//	space for dest records
		if (gDests == nil) {
			return atalk_HDL_NONE;
		}
	}
	
	for (i = 0; i < MAX_DESTS; i++) {
		if (!gDests[i].inUse) {
			break;
		}
	}
	
	OTInitDDPAddress(&gDests[i].dest_addr, ip_dst->fNetwork, ip_dst->fNodeID, ip_dst->fSocket, 0);
	
	gDests[i].inUse = true;
	gDests[i].flags = flags;
	
	*local_port = 0;			//	never used
	
	return i;
}
예제 #10
0
파일: network_ddp.c 프로젝트: DrItanium/moo
DDPFramePtr NetDDPNewFrame(
    void)
{
    DDPFramePtr frame= (DDPFramePtr) NewPtrClear(sizeof(DDPFrame));

    return frame;
}
예제 #11
0
파일: network_ddp.c 프로젝트: DrItanium/moo
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;
}
예제 #12
0
void PAS_sortIDs(short sourceRefNum, OSType theType, short **IdPtr, long *count)
{
	short				oldRef;
	Handle				theHandle;
	short				resCount;
	short				resIndex;
	
	*count	=	-1;
	
	oldRef = CurResFile();
		
	UseResFile(sourceRefNum);

	resCount = Count1Resources(theType);
	
	*IdPtr	=	(short*) NewPtrClear( resCount * sizeof(short) );
	
	for (resIndex=1; resIndex <= resCount; resIndex++)
	{
		theHandle = Get1IndResource(theType, resIndex);
		
		if(theHandle == NULL) return;
	
		(*IdPtr)[resIndex-1] = PAS_getResourceID(theHandle);
		
		ReleaseResource(theHandle);
	}
	
	UseResFile(oldRef);
	
	PAS_bubbleSortIDS(*IdPtr, resCount);
	
	
	*count = resCount;
}
예제 #13
0
char * ReadDataFile (long * pBufferSize, FSSpec * pfsspecData)
{
	NavReplyRecord replyNav;
	NavTypeListHandle hTypeList = (NavTypeListHandle) NewHandleClear (sizeof (NavTypeList) + sizeof (OSType) * 1);
	AEKeyword theKeyword;
	DescType actualType;
	Size actualSize;
	OSStatus err = noErr;
    short fileRef;
    char * pFileBuffer;

	HLock ((Handle) hTypeList);
	(**hTypeList).osTypeCount = 2;
	(**hTypeList).osType[0] = 'TEXT';
	(**hTypeList).osType[1] = '????';

    // select sprite file
	err = NavChooseFile (NULL, &replyNav, NULL, NULL, NULL, NULL, hTypeList, NULL); 
	if ((err == noErr) && (replyNav.validRecord))
		err = AEGetNthPtr (&(replyNav.selection), 1, typeFSS, &theKeyword, &actualType,
						   pfsspecData, sizeof (FSSpec), &actualSize);
	NavDisposeReply (&replyNav);
	if (err != noErr)
		return false;
    FSpOpenDF(pfsspecData, fsRdPerm, &fileRef);
    GetEOF(fileRef, pBufferSize);
    pFileBuffer = (char *) NewPtrClear (*pBufferSize);
    FSRead (fileRef, pBufferSize, pFileBuffer);
    FSClose (fileRef);
	return pFileBuffer;
}
예제 #14
0
파일: mem.c 프로젝트: osgcc/descent-mac
void * mem_malloc( unsigned int size, char * var, char * filename, int line, int fill_zero )
{
	unsigned int base;
	void *ptr;
	int * psize, i;

	if (Initialized==0)
		mem_init();

	if (size==0)	{
		Warning("Attempt to malloc 0 bytes.\nVar %s, file %s, line %d.\n", var, filename, line);
		Error( "MEM_MALLOC_ZERO" );
	}
	
	ptr = (void *)NewPtrClear( size + CHECKSIZE );		// clear when allocated

	if (ptr==NULL)	{
		Warning("Malloc returned NULL\nVar %s, file %s, line %d.\n", var, filename, line );
		Error( "MEM_OUT_OF_MEMORY" );
	}
	base = (unsigned int)ptr;
//	Free_heap_space = FreeMem();

	check_mem_conditions();	
	return ptr;
}
예제 #15
0
unsigned tcpabi_udp_open( unsigned long ip_dst, unsigned dst_port,
                          unsigned src_port,
                          unsigned char flags, unsigned *local_port ) {
    unsigned long		i;

    //	save all of the paramaters in our array and return the index
    //	that we just used

    if (gDests == nil) {
        gDests = (DestStruct*) NewPtrClear(sizeof(DestStruct) * MAX_DESTS);		//	space for dest records
        if (gDests == nil) {
            return trump_HDL_NONE;
        }
    }

    for (i = 0; i < MAX_DESTS; i++) {
        if (!gDests[i].inUse) {
            break;
        }
    }

    OTInitInetAddress(&gDests[i].dest_addr, dst_port, ip_dst);

    gDests[i].inUse = true;
    gDests[i].ipDest = ip_dst;
    gDests[i].portDest = dst_port;
    gDests[i].portSource = src_port;
    gDests[i].flags = flags;

    *local_port = 0;			//	never used

    return i;
}
// Component Open Request - Required
pascal ComponentResult DelegateOnly_ImageCodecOpen(DelegateOnly_Globals glob, ComponentInstance self)
{
	ComponentDescription cd = { decompressorComponentType, k422YpCbCr8CodecType, FOUR_CHAR_CODE('app3'), 0, 0 };
	Component c = 0;
	
	ComponentResult rc;
	
	// Allocate memory for our globals, set them up and inform the component manager that we've done so
	glob = (DelegateOnly_Globals)NewPtrClear(sizeof(DelegateOnly_GlobalsRecord));
	if (rc = MemError()) goto bail;
	
	SetComponentInstanceStorage(self, (Handle)glob);
	
	glob->self = self;
	glob->target = self;
	
	if (c = FindNextComponent(c, &cd)) {
		
		rc = OpenAComponent(c, &glob->delegateComponent);
		if (rc) goto bail;

		ComponentSetTarget(glob->delegateComponent, self);
	}

bail:
	return rc;
}
예제 #17
0
파일: TinyMSL.c 프로젝트: amatubu/iconparty
void * calloc(size_t nmemb, size_t size)
{
	void *result;
	
	result = (void *)NewPtrClear(nmemb * size);
	
	return result;
}
예제 #18
0
void
InitControlsObject(void)
{	
	gControls 		= (InstWiz *) 		NewPtrClear(sizeof(InstWiz));
	if (!gControls)
	{
        ErrorHandler(eMem, nil);
		return;
	}
	
	gControls->lw 	= (LicWin *) 		NewPtrClear(sizeof(LicWin));
	gControls->ww 	= (WelcWin *) 		NewPtrClear(sizeof(WelcWin));
	gControls->stw 	= (SetupTypeWin *) 	NewPtrClear(sizeof(SetupTypeWin));	
	gControls->cw 	= (CompWin *) 		NewPtrClear(sizeof(CompWin));
	gControls->aw 	= (CompWin *) 		NewPtrClear(sizeof(CompWin));
	gControls->tw 	= (TermWin*) 		NewPtrClear(sizeof(TermWin));

	if (!gControls->lw || !gControls->ww || !gControls->stw || 
		!gControls->cw || !gControls->tw)
	{
        ErrorHandler(eMem, nil);
	}
	
	gControls->state = eInstallNotStarted;
	
	return;
}
예제 #19
0
void *_calloc_r(struct _reent *reent_ptr, size_t sz, size_t sz2)
{
	Ptr p = NewPtrClear(sz*sz2);

	if(!p)
		errno = ENOMEM;

	return p;
}
예제 #20
0
OSErr TotalHack(CFragConnectionID connID)
{
	Handle				theStrings;
	CMBufferSizes		bufSizes;
	short					procID;
	Str255				toolName;
	OSErr					error;
	FSSpec				where;
	short					ref;
	char*					end;
	Ptr					tempString;
	char*					here;
	short					baud;
	Boolean				prefsChanged = false;
	THz					myZone;
	ser_t*				storage;
	gConnection = nil;

	// get a Connection Tool name
	strcpy((char *)toolName, "Apple Modem Tool");						// so try to use the Apple modem tool
	c2pstr((char *)toolName);
	end = (char *)(toolName + toolName[0] + 1);
	memset(end, '\0', 255 - toolName[0]);
	// init the CMBufferSizes variable so that Tool will init with defaults

	bufSizes[cmDataIn] = 0;
	bufSizes[cmDataOut] = 0;
	bufSizes[cmCntlIn] = 0;
	bufSizes[cmCntlOut] = 0;
	bufSizes[cmAttnIn] = 0;
	bufSizes[cmAttnOut] = 0;
	bufSizes[cmRsrvIn] = 0;
	bufSizes[cmRsrvOut] = 0;

	error = noErr;
	myZone = GetZone();
	SetZone(SystemZone());
	// get a process ID for the tool
	procID = CMGetProcID(toolName);
	if (procID == -1) {
		error = -2;
	}

	// now get a conn record set up
	if (error == noErr) {
		gConnection = CMNew(procID, cmData|cmNoMenus|cmQuiet, bufSizes, 0, 0);
		if (gConnection != nil) {
			storage = (ser_t*)NewPtrClear(sizeof(ser_t));
			storage->sConnection = gConnection;
			error = SetData(connID, (unsigned long)storage);
		}
	}

	return error;
}
예제 #21
0
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;
        }
    }
}
예제 #22
0
void
WhackDirectories(char *filename)
{
	// Level ouot essential files and components to satisfy
	// lib loading and dependency resolution issues
	
	Ptr		componentPathStr 	= 0;
	Ptr		tempStr				= 0;
	Ptr		finalStr			= 0;
	long	prefixLen			= 0;
	long    skipLen             = 0;
	
	componentPathStr = NewPtrClear(strlen(filename) + 1);
	finalStr		 = NewPtrClear(strlen(filename) + 1);
	strcpy(componentPathStr, filename);				// e.g. HD:Target:Essential Files:foo.shlb
													//   or HD:Target:Components:bar.shlb
	LowercaseText(componentPathStr, strlen(componentPathStr), smSystemScript);
	if((tempStr = strstr(componentPathStr, "essential files")) != NULL)
	{
		prefixLen = tempStr - componentPathStr;		// e.g. HD:Target:

		strncpy(finalStr, filename, prefixLen);  	// e.g. HD:Target:
		skipLen = prefixLen + strlen("essential files") + 1;  // add 1 to skip over extra ':'
		strcat(finalStr, filename + skipLen);
		strcpy(filename, finalStr);
	}
	else
	if ((tempStr = strstr(componentPathStr, "components")) != NULL)
	{
		prefixLen = tempStr - componentPathStr;		// e.g. HD:Target:

		strncpy(finalStr, filename, prefixLen);  	// e.g. HD:Target:
		skipLen = prefixLen + strlen("components") + 1;  // add 1 to skip over extra ':'
		strcat(finalStr, filename + skipLen);
		strcpy(filename, finalStr);					// e.g. HD:Target:foo.shlb
	}

	if(componentPathStr)
		DisposePtr(componentPathStr);
	if(finalStr)
		DisposePtr(finalStr);
}
예제 #23
0
ALAPI ALCdevice *alcOpenDevice( const ALubyte *tokstr )
{
	// allow opening of one device
	if (pOpenDevice != 0)
	{
		pOpenDevice = (ALCdevice *) NewPtrClear(sizeof(ALCdevice));
		return pOpenDevice;
	} else
	{
		return 0;
	}
}
void * memoryAllocate(int number,unsigned size) {
    void * stuff;
#if defined(TARGET_OS_MAC) && !defined ( __APPLE__ ) && !defined ( __MACH__ )
#if TARGET_API_MAC_CARBON
    stuff = (void *) NewPtrClear(size*number);
#else
    stuff = (void *) NewPtrSysClear(size*number);
#endif
//    if (stuff == nil) Debugger();
#else
    stuff = (void *) calloc(size,number);
#endif
    counter++;
    return stuff;
}
예제 #25
0
void *pgp_mallocclear(long len)
{
#ifdef	PGP_MACINTOSH
	Ptr temp;

	/* allocate a block of desiredLen and clear it to 0 */
	temp = NewPtrClear(len);
	pgpAssert(IsntNull(temp));
	return temp;
#elif	PGP_WIN32
	void	*ptr = pgp_malloc(len);

	memset(ptr, 0, len);
	return ptr;
#endif
}
예제 #26
0
void *my_calloc (int n, int s)
{
	int i = MaxBlock ();
	void *x;

	if (n * s >= i) {
		printf ("Error: calloc = %d,%d, maxblock = %d\n", n, s, i);
		exit (-1);
	}

	if ((x = (void *)NewPtrClear(n * s)) == NULL) {
		printf ("Error: %d\n", MemError());
		exit (-1);
	}
	
	return x;
}
예제 #27
0
void SortVirtuals()
{
    SYMBOL	*Sym;
    int		n, i, vCount;

    vCount = GetVirtualIndex();

    if (!vCount)
        return;

//	printf("\nVIRTUALS (%d)\n\n", vCount);

    vtable = (int *) NewPtrClear((vCount+2) * sizeof(int *));

    if (!vtable)
        return;

    Sym = SymTab;
    n = SYMMAX;

    do
    {
        if ((Sym->Section == section_Enum) && (Sym->LocalScope != 0))
        {
            if (Sym->LabelType == label_Virtual)
            {
                i = Sym->VirtualIndex & 0xffff;
                vtable[i] = (int) Sym;
            }
        }

        Sym++;
    }
    while(--n);

    /*	for (n=0;n<vCount;n++)
    	{
    		Sym = (SYMBOL *) vtable[n];

    		if (print)
    			DumpEnumEntry(Sym);
    	}
    */
    return;
}
예제 #28
0
파일: alSource.c 프로젝트: Aye1/RVProject
ALAPI ALvoid ALAPIENTRY alQueuei (ALuint source, ALenum param, ALint value)
{
	QueueEntry *ptrQE, *tempPtr;
	
	if (alIsSource(source))
	{
		switch(param) 
		{
			case AL_BUFFER:
#ifdef MAC_OS_X
                                ptrQE = (void *)malloc(sizeof(QueueEntry));
                                memset(ptrQE, 0, sizeof(QueueEntry));
#else
				ptrQE = (void *)NewPtrClear(sizeof(QueueEntry));
#endif
				ptrQE->bufferNum = value;
				ptrQE->processed = AL_FALSE;
				ptrQE->pitch = gSource[source].pitch;
				ptrQE->gain = gSource[source].gain;
				ptrQE->loopDirection = AL_FALSE; // ***** need to implement real loop directions
				
				tempPtr = gSource[source].ptrQueue;
				if (tempPtr != NULL)
				{
					while (tempPtr->pNext != NULL)
					{
						tempPtr = tempPtr->pNext;
					}
					tempPtr->pNext = ptrQE;
				} else
				{
					gSource[source].ptrQueue = ptrQE;
				}
				break;
			default:
				alSetError(AL_INVALID_ENUM);
				break;
	
		}
	} else
	{
		alSetError(AL_INVALID_NAME);
	}
}
예제 #29
0
파일: music.c 프로젝트: DrItanium/moo
/* If channel is null, we don't initialize */
boolean initialize_music_handler(
	FileDesc *song_file)
{
	short song_file_refnum;
	OSErr error;

	assert(music_state==NULL);
	assert(NUMBER_OF_SONGS==sizeof(songs)/sizeof(struct song_definition));
		
	/* Does the file exist? */
	error= FSpOpenDF((FSSpec *) song_file, fsRdPerm, &song_file_refnum);
	if(!error && song_file_refnum>0)
	{
		music_state= (struct music_data *) NewPtrClear(sizeof(struct music_data));
		if(music_state)
		{
			music_state->initialized= TRUE;
			music_state->flags= 0;
			music_state->state= _no_song_playing;
			music_state->phase= 0;
			music_state->song_index= 0;
			music_state->next_song_index= NONE;
			music_state->song_file_refnum= song_file_refnum;
			music_state->completion_proc= NewFilePlayCompletionProc(file_play_completion_routine);
			music_state->ticks_at_last_update= TickCount();

			/* Allocate our buffer */
			music_state->sound_buffer_size= kDefaultSoundBufferSize;
			music_state->sound_buffer= NULL;
			
//			music_state->sound_buffer= malloc(music_state->sound_buffer_size);
//			assert(music_state->sound_buffer);

			allocate_music_channel();

			assert(music_state->completion_proc);
			atexit(shutdown_music_handler);
		}
	}
	
	return (music_state!=NULL);
}
예제 #30
0
OSErr ReopenCTBConnection(ConnHandle* connection) {
	Str255				toolName;
	Ptr					configStream;
	EventRecord			event;
	Rect				dialogLoc;
	OSErr				error;

	if (*connection != nil) {
		// Get the configuration from the prefs, or fail
		configStream = NewPtrClear(256);
		error = GetConfig(configStream);
		if (error == noErr) {
			//	configure the connection
			error = CMSetConfig(*connection, configStream);
			error = CMOpen(*connection, false, nil, 0);
		}
	}
			
	return error;	
}