Ejemplo n.º 1
0
void InitThinkers(void)
{
    ResetPlats();				/* Reset the platforms */
    ResetCeilings();			/* Reset the ceilings */
	if (mobjhead.next) {		/* Initialized before? */
		mobj_t *m,*NextM;
		m=mobjhead.next;
		while (m!=&mobjhead) {	/* Any player object */
			NextM = m->next;		/* Get the next record */
			DeallocAPointer(m);	/* Delete the object from the list */
			m=NextM;
		}
	}
	if (thinkercap.next) {
		thinker_t *t,*NextT;
		t = thinkercap.next;
		while (t!=&thinkercap) {	/* Is there a think struct here? */
			NextT = t->next;
			DeallocAPointer(t);		/* Delete it from memory */
			t = NextT;
		}
	}
	thinkercap.prev = thinkercap.next  = &thinkercap;	/* Loop around */
	mobjhead.next = mobjhead.prev = &mobjhead;		/* Loop around */
}
Ejemplo n.º 2
0
void BURGERCALL vorbis_comment_clear(vorbis_comment *vc){
  if(vc){
    long i;
    for(i=0;i<vc->comments;i++)
      if(vc->user_comments[i])DeallocAPointer(vc->user_comments[i]);
    if(vc->user_comments)DeallocAPointer(vc->user_comments);
	if(vc->comment_lengths)DeallocAPointer(vc->comment_lengths);
    if(vc->vendor)DeallocAPointer(vc->vendor);
  }
  FastMemSet(vc,0,sizeof(*vc));
}
Ejemplo n.º 3
0
void BURGERCALL JoystickDestroy(void)
{
	MacInput_t *LocalPtr;
	LocalPtr = &MacInputLocals;
	MacInputDestroy(LocalPtr,MACINITINPUTJOYSTICK);
	DeallocAPointer(LocalPtr->JoystickDescriptionsArray);	/* Release the input sources */
	DeallocAPointer(LocalPtr->JoystickDeviceArray);		/* Release the devices */

	LocalPtr->JoystickDescriptionsArray = 0;
	LocalPtr->JoystickDeviceArray = 0;
	JoystickPresent = 0;		/* No joysticks are present */
}
Ejemplo n.º 4
0
void BURGERCALL RedbookDelete(Redbook_t *Input)
{
	if (Input) {
		RedbookDestroy(Input);		/* Discard the contents */
		DeallocAPointer(Input);		/* Dispose of the pointer */
	}
}
Ejemplo n.º 5
0
void BURGERCALL LinkedListDeleteEntry(LinkedList_t *Input,LinkedListEntry_t *EntryPtr)
{
	LinkedListEntry_t *Next;
	LinkedListEntry_t *Prev;

	Next = EntryPtr->Next;	/* Prefetch the next entry */
	Prev = EntryPtr->Prev;	/* Prefetch the prev entry */
	Input->Count--;			/* 1 less */
	if (Input->First == EntryPtr) {		/* Was this the first one? */
		Input->First = Next;			/* Set the new root */
	}
	if (Input->Last == EntryPtr) {		/* Was this the last one? */
		Input->Last = Prev;				/* Set the new tail */
	}
	if (Prev) {					/* Shall I unlink? */
		Prev->Next = Next;		/* Set the new next link */
	}
	if (Next) {
		Next->Prev = Prev;		/* Set the new prev link */
	}

		/* Now kill the data if needed */

	if (EntryPtr->KillProc) {	/* Is there a destructor? */
		EntryPtr->KillProc(EntryPtr);	/* Call the proc */
	} else {
		DeallocAPointer(EntryPtr);			/* Kill the entry itself */
	}
}
Ejemplo n.º 6
0
void BURGERCALL LinkedListDelete(LinkedList_t *Input)
{
	if (Input) {
		LinkedListDestroy(Input);		/* Kill the list */
		DeallocAPointer(Input);			/* Dispose of the structure */
	}
}
Ejemplo n.º 7
0
void PurgeLineSpecials(void)
{
	if (linespeciallist) {		/* Is there a valid pointer? */
		DeallocAPointer(linespeciallist);	/* Release it */
		linespeciallist = 0;
		numlinespecials = 0;	/* No lines */
	}
}
Ejemplo n.º 8
0
void BURGERCALL vorbis_comment_add_tag(vorbis_comment *vc, char *tag, char *contents){
  char *comment=static_cast<char *>(AllocAPointer(strlen(tag)+strlen(contents)+2)); /* +2 for = and \0 */
  strcpy(comment, tag);
  strcat(comment, "=");
  strcat(comment, contents);
  vorbis_comment_add(vc, comment);
  DeallocAPointer(comment);
}
Ejemplo n.º 9
0
static void RemoveMeThink(thinker_t *Current)
{
	thinker_t *Next;
	thinker_t *Prev;
	--Current;			/* Index to the REAL pointer */
	Next = Current->next;
	Prev = Current->prev;
	Next->prev = Prev;	/* Unlink it */
	Prev->next = Next;
	DeallocAPointer(Current);		/* Release the memory */
}
Ejemplo n.º 10
0
void BURGERCALL MADSndClose(MADDriverRec *inMADDriver)
{
	if (inMADDriver->MusicChannelPP) {
		SndDisposeChannel(inMADDriver->MusicChannelPP,TRUE);
		inMADDriver->MusicChannelPP = 0;
	}
	if (inMADDriver->CallBackUPP) {
		DisposeSndCallBackUPP(inMADDriver->CallBackUPP);
		inMADDriver->CallBackUPP = 0;
	}
	DeallocAPointer(inMADDriver->SndBuffer);
	inMADDriver->SndBuffer = 0;
}
Ejemplo n.º 11
0
char *BURGERCALL vorbis_comment_query(vorbis_comment *vc, char *tag, int count)
{
	long i;
	int found = 0;
	int taglen = strlen(tag)+1; /* +1 for the = we append */
	char *fulltag = static_cast<char *>(AllocAPointer(taglen+ 1));

	strcpy(fulltag, tag);
	strcat(fulltag, "=");

	for(i=0;i<vc->comments;i++){
		if(!tagcompare(vc->user_comments[i], fulltag, taglen)){
			if(count == found) {
				/* We return a pointer to the data, not a copy */
				DeallocAPointer(fulltag);
				return vc->user_comments[i] + taglen;
			} else {
				found++;
			}
		}
	}
	DeallocAPointer(fulltag);
	return NULL; /* didn't find anything */
}
Ejemplo n.º 12
0
void BURGERCALL vorbis_info_clear(vorbis_info *vi){
  codec_setup_info     *ci=static_cast<codec_setup_info *>(vi->codec_setup);
  int i;

  if(ci){

    for(i=0;i<ci->modes;i++)
      if(ci->mode_param[i])DeallocAPointer(ci->mode_param[i]);

    for(i=0;i<ci->maps;i++) /* unpack does the range checking */
      _mapping_P[ci->map_type[i]]->free_info(ci->map_param[i]);

    for(i=0;i<ci->times;i++) /* unpack does the range checking */
      _time_P[ci->time_type[i]]->free_info(ci->time_param[i]);

    for(i=0;i<ci->floors;i++) /* unpack does the range checking */
      _floor_P[ci->floor_type[i]]->free_info(ci->floor_param[i]);
    
    for(i=0;i<ci->residues;i++) /* unpack does the range checking */
      _residue_P[ci->residue_type[i]]->free_info(ci->residue_param[i]);

    for(i=0;i<ci->books;i++){
      if(ci->book_param[i]){
	/* knows if the book was not alloced */
	vorbis_staticbook_destroy(ci->book_param[i]);
      }
    }
    
    for(i=0;i<ci->psys;i++)
      _vi_psy_free(ci->psy_param[i]);

    DeallocAPointer(ci);
  }

  FastMemSet(vi,0,sizeof(*vi));
}
Ejemplo n.º 13
0
int BURGERCALL vorbis_comment_query_count(vorbis_comment *vc, char *tag){
	int i,count=0;
	int taglen = strlen(tag)+1; /* +1 for the = we append */
	char *fulltag = static_cast<char *>(AllocAPointer(taglen+1));
	strcpy(fulltag,tag);
	strcat(fulltag, "=");

	for(i=0;i<vc->comments;i++){
		if(!tagcompare(vc->user_comments[i], fulltag, taglen)) {
			count++;
		}
	}
	DeallocAPointer(fulltag);
	return count;
}
Ejemplo n.º 14
0
static pascal OSErr HandleOdoc(const AEDescList *aevt, AEDescList *reply,long refCon) 
{
	AEDesc FileListDescription;
	DescType MyFileType;
	long DataSize;
	AEKeyword MyKeyword;
	FSSpec TheFileSpec;
	Word i;
	Foo_t *FooPtr;
						
	/* First, I see if any files are present */
	
	FileListDescription.descriptorType = typeWildCard;		/* Any file */
	FileListDescription.dataHandle = 0;				/* No handle (Yet) */
	
	if (!AEGetKeyDesc(aevt,keyDirectObject,typeAEList,&FileListDescription)) {
		
		/* Now load each and every file */

		i = 1;
		FooPtr = (Foo_t *)refCon;
		while (!AEGetNthPtr(&FileListDescription,i,typeFSS,&MyKeyword,&MyFileType,(Ptr)&TheFileSpec,sizeof(FSSpec),&DataSize)) {
			char CurrentName[256];
			char *DirName;
			if (TheFileSpec.name[0]) {		/* Must have some name! */
				PStr2CStr(CurrentName,(char *)TheFileSpec.name);	/* Convert to "C" */
				TheFileSpec.name[0] = 0;	/* Zap the filename */
				DirName = GetFullPathFromMacFSSpec(&TheFileSpec);	/* Get the directory */
				if (DirName) {
					SetAPrefix(8,DirName);		/* Set my directory */
					DeallocAPointer(DirName);
					FooPtr->Result = FALSE;		/* Hit me! */
					if (FooPtr->Proc(CurrentName)) {	/* Process the file */
						break;
					}
				}
			}
			++i;		/* Next */
		}
	}
	AEDisposeDesc(&FileListDescription);		/* Release the file list */
	return noErr;
}
Ejemplo n.º 15
0
void BURGERCALL LinkedListDestroy(LinkedList_t *Input)
{
	LinkedListEntry_t *EntryPtr;
	EntryPtr = Input->First;		/* Is there data here? */
	if (EntryPtr) {					/* Yep, kill it */
		do {
			LinkedListEntry_t *Next;
			Next = EntryPtr->Next;	/* Prefetch the next entry */
			if (EntryPtr->KillProc) {	/* Is there a destructor? */
				EntryPtr->KillProc(EntryPtr);	/* Call the proc */
			} else {
				DeallocAPointer(EntryPtr);
			}
			EntryPtr = Next;				/* Next entry */
		} while (EntryPtr);					/* Any more? */
	}
	Input->First = 0;					/* Zap the data */
	Input->Last = 0;
	Input->Count = 0;
}
Ejemplo n.º 16
0
Word BURGERCALL JoystickInit(void)
{
	Word32 TempLong;
	Word i;
	MacInput_t *LocalPtr;
	
	LocalPtr = &MacInputLocals;
	if (!MacInputInit(LocalPtr,MACINITINPUTJOYSTICK)) {	/* 1.3 or better? */
	
		/* Discard any previous data from a previous call */
		/* This will allow simple rescanning */

		DeallocAPointer(LocalPtr->JoystickDescriptionsArray);
		DeallocAPointer(LocalPtr->JoystickDeviceArray);
		LocalPtr->JoystickDescriptionsArray = 0;
		LocalPtr->JoystickDeviceArray = 0;
		{
			Word *Boundaries;
			i = 0;
			Boundaries = &JoystickBoundaries[0][0];		/* Init pointer to struct */
			do {
				Word j;
				j = 0;
				do {
					Boundaries[AXISMIN] = 0x100000;	/* Init center point */
					Boundaries[AXISMAX] = 0xF00000;
					Boundaries[AXISCENTER] = 0x800000;
					Boundaries+=AXISENTRIES;
					JoystickSetDigital(j,20,i);		/* Create the digital bounds */
				} while (++j<AXISCOUNT);
			} while (++i<MAXJOYNUM);		/* All of them checked? */
		}

		MacInputLockInputSprocket();				/* Don't allow mouse/keyboard IRQ's */
		
		if (ISpDevices_Extract(0,&TempLong,0)) {		/* How many devices are present? */
			goto Abort;
		}
		i = TempLong;				/* Save in register */
		LocalPtr->JoystickDeviceArray = (ISpDeviceReference *)AllocAPointer(sizeof(ISpDeviceReference)*i);
		if (!LocalPtr->JoystickDeviceArray) {		/* Memory allocation error? */
			goto Abort;
		}
		if (ISpDevices_Extract(i,&TempLong,LocalPtr->JoystickDeviceArray)) {	/* Get the devices */
			goto Abort;
		}

		/* Now remove all devices that are not mice or keyboards */

		JoystickPresent = i;		/* Save the device count */
		if (i) {
			ISpDeviceReference *ArrayPtr;
			ISpDeviceReference *ArrayPtr2;

			ArrayPtr = LocalPtr->JoystickDeviceArray;
			ArrayPtr2 = ArrayPtr;
			do {
				ISpDeviceDefinition ResultBuf;		/* Get the device definition */
				if (!ISpDevice_GetDefinition(ArrayPtr[0],sizeof(ISpDeviceDefinition),&ResultBuf)) {
					if (ResultBuf.theDeviceClass != kISpElementLabel_None) {
						if ((ResultBuf.theDeviceClass != kISpDeviceClass_Mouse) &&
							(ResultBuf.theDeviceClass != kISpDeviceClass_Keyboard)) {
							ArrayPtr2[0] = ArrayPtr[0];
							++ArrayPtr2;
						}
					}
				}
				++ArrayPtr;
			} while (--i);
			JoystickPresent = ArrayPtr2-LocalPtr->JoystickDeviceArray;
		}

		
		/* At this point I have all the devices I am going to use. Now */
		/* I will get the actual input methods and create a map for each one */

		i = JoystickPresent;
		if (i) {
			Word j;
			JoyDesc_t *JoyDevPtr;

			if (i>MAXJOYNUM) {			/* I can only have 4 input devices */
				i = MAXJOYNUM;
				JoystickPresent = MAXJOYNUM;
			}

			JoyDevPtr = (JoyDesc_t *)AllocAPointerClear(sizeof(JoyDesc_t)*i);
			if (!JoyDevPtr) {
				goto Abort;
			}
			j = 0;
			LocalPtr->JoystickDescriptionsArray = JoyDevPtr;
			do {

				/* For each device, scan the input elements and find a burgerlib */
				/* match, assign it a button, pad or axis id */

				ISpElementListReference MyElementList;
				if (!ISpDevice_GetElementList(LocalPtr->JoystickDeviceArray[j],&MyElementList)) {
					Word32 ElementCount;
					ISpElementReference ElementBuf[500];
					if (!ISpElementList_Extract(MyElementList,500,&ElementCount,ElementBuf)) {
						if (ElementCount) {
							Word TempIndex;
							Word FooIndex;
							Word AxisIndex;
							Word ButtonIndex;

							TempIndex = 0;
							AxisIndex = 0;		/* No axis' found */
							ButtonIndex = 0;	/* No buttons found */
							do {
								ISpElementInfo ElementInfo;
								ISpElementReference CurrentRef;

								CurrentRef = ElementBuf[TempIndex];
								if (!ISpElement_GetInfo(CurrentRef,&ElementInfo)) {
									/* I've got input, what kind of input is it? */

									switch (ElementInfo.theKind) {
									case kISpElementKind_Button:		/* Simple button */
										if (ButtonIndex<20) {
											JoyDevPtr->Elements[ButtonIndex+ELEMENTBUTTON] = CurrentRef;
											++ButtonIndex;
										}
										break;

									/* Hat or pad */

									case kISpElementKind_DPad:			/* Hat/Pad */

									/* If the ID is a hat, place it in the hat slot first */

										if (ElementInfo.theLabel==kISpElementLabel_Pad_POV ||
											ElementInfo.theLabel==kISpElementLabel_Pad_POV_Horiz) {
											if (!JoyDevPtr->Elements[ELEMENTPAD+1]) {
												JoyDevPtr->Elements[ELEMENTPAD+1] = CurrentRef;
												break;
											}
										}
										FooIndex = 0;
										do {
											if (!JoyDevPtr->Elements[FooIndex+ELEMENTPAD]) {
												 JoyDevPtr->Elements[FooIndex+ELEMENTPAD] = CurrentRef;
												 break;
											}
										} while (++FooIndex<2);
										break;

									/* Handle joystick axis' */
									
									case kISpElementKind_Axis:			/* Joystick axis */
									case kISpElementKind_Delta:
										if (ElementInfo.theLabel==kISpElementLabel_Axis_XAxis) {
											if (!JoyDevPtr->Elements[ELEMENTAXIS]) {
												JoyDevPtr->Elements[ELEMENTAXIS] = CurrentRef;
												JoyDevPtr->ElementData[ELEMENTAXIS] = 0x7FFFFFFF;
												break;
											}
											if (!JoyDevPtr->Elements[ELEMENTAXIS+4]) {
												JoyDevPtr->Elements[ELEMENTAXIS+4] = CurrentRef;
												JoyDevPtr->ElementData[ELEMENTAXIS+4] = 0x7FFFFFFF;
												break;
											}
										} else if (ElementInfo.theLabel==kISpElementLabel_Axis_YAxis) {
											if (!JoyDevPtr->Elements[ELEMENTAXIS+1]) {
												JoyDevPtr->Elements[ELEMENTAXIS+1] = CurrentRef;
												JoyDevPtr->ElementData[ELEMENTAXIS+1] = 0x7FFFFFFF;
												break;
											}
											if (!JoyDevPtr->Elements[ELEMENTAXIS+5]) {
												JoyDevPtr->Elements[ELEMENTAXIS+5] = CurrentRef;
												JoyDevPtr->ElementData[ELEMENTAXIS+5] = 0x7FFFFFFF;
												break;
											}
										} else if (ElementInfo.theLabel==kISpElementLabel_Axis_ZAxis) {
											if (!JoyDevPtr->Elements[ELEMENTAXIS+2]) {
												JoyDevPtr->Elements[ELEMENTAXIS+2] = CurrentRef;
												JoyDevPtr->ElementData[ELEMENTAXIS+2] = 0x7FFFFFFF;
												break;
											}
										}
										/* Insert in the generic list */
										
										if (AxisIndex<AXISCOUNT) {
											do {
												if (!JoyDevPtr->Elements[AxisIndex+ELEMENTAXIS]) {
													JoyDevPtr->Elements[AxisIndex+ELEMENTAXIS] = CurrentRef;
													JoyDevPtr->ElementData[AxisIndex+ELEMENTAXIS] = 0x7FFFFFFF;
													break;
												}
											} while (++AxisIndex<AXISCOUNT);
										}
										break;
									}
								}
							} while (++TempIndex<ElementCount);
						}
					}
				}
				++JoyDevPtr;
			} while (++j<i);			/* All devices scanned */
		}
		MacInputUnlockInputSprocket();
		return JoystickPresent;
	}
Abort:;
	MacInputUnlockInputSprocket();
	JoystickDestroy();
	return 0;
}
Ejemplo n.º 17
0
void BURGERCALL LinkedListSort(LinkedList_t *Input,LinkedListSortProc Proc)
{
	LinkedListEntry_t **ArrayPtr;
	
	LinkedListEntry_t *Internal[2000];
	
	/* Simple sort? */
	
	if (Input->Count>=2) {				/* Should I even worry about a sort? */
	
		/* Two entries? */
		
		if (Input->Count==2) {			/* I guess so... */
			LinkedListEntry_t *First;
			LinkedListEntry_t *Second;
			First = Input->First;		/* Just a two entry sort, trivial... */
			Second = Input->Last;
			if (Proc(First->Data,Second->Data)>0) {		/* Worry? */
				Input->First = Second;					/* Perform a swap */
				Input->Last = First;
				Second->Next = First;		/* New first entry */
				Second->Prev = 0;
				First->Next = 0;			/* New last entry */
				First->Prev = Second;
			}
			return;							/* I am sorted */
		}
		
		/* Let's perform a merge sort */
		
		/* First get the buffer for the sort */
		
		if (Input->Count>1000) {
			ArrayPtr = (LinkedListEntry_t **)AllocAPointer(sizeof(LinkedListEntry_t *)*Input->Count*2);	/* Yikes!! */
			if (!ArrayPtr) {			/* Memory error! */
				return;					/* Forget about the sort! */
			}
		} else {
			ArrayPtr = Internal;		/* Use my internal buffer */
		}
		
		/* I need to first "flatten" the linked list */
		
		{	
			LinkedListEntry_t **WorkPtr1;
			LinkedListEntry_t *EntryPtr1;
			Word i1;
			WorkPtr1 = ArrayPtr;				/* Pointer to the allocated buffer */
			i1 = Input->Count;					/* Number of entries to upload */
			EntryPtr1 = Input->First;
			do {
				WorkPtr1[0] = EntryPtr1;		/* Store the entry */
				EntryPtr1 = EntryPtr1->Next;	/* Next one in the chain */
				++WorkPtr1;
			} while (--i1);					/* All done */
		}
		
		/* Now, we perform the merge sort */
		
		{
			LinkedListEntry_t **WorkPtr;
			{
				Word i;
				Word size;	/* Entry size to sort with */
				Word sort;	/* Sort count */
				LinkedListEntry_t **unsorted;
			    
				i = Input->Count;			/* How many entries are there? */	
				size = 1;						/* source size		(<<1 / loop)*/
				sort = 1;						/* iteration number (+1 / loop)*/
				WorkPtr = ArrayPtr;
				unsorted = ArrayPtr+i;
				do {
					{
						Word remaining;								/* Temp merge count */
						LinkedListEntry_t **src1,**src2,**dest;		/* Used by the sort */
						remaining = i>>sort;						/* How many times to try */
					
						/* pointers incremented by the merge */
						
						src1 = WorkPtr;								/* Sorted array */
						src2 = &WorkPtr[remaining<<(sort-1)];		/* Half point */
						dest = unsorted;	/* Dest array */
					
						/* merge paired blocks*/
						if (remaining) {	/* Any to sort? */
							do {
								LinkedListMerge(dest,src1,src2,size,size,Proc);	/* All groups equal size */
								dest = &dest[size+size];
								src1 = &src1[size];
								src2 = &src2[size];
							} while (--remaining);
						}
					
						/* copy or merge the leftovers */
						remaining = i&((size<<1)-1);	/* Create mask (1 bit higher) */
						if (remaining > size) {	/* one complete block and one fragment */
							LinkedListMerge(dest,&src2[size],src2,remaining-size,size,Proc);
						} else if (remaining) {	/* just a single sorted fragment */
							FastMemCpy(dest,src2,remaining*sizeof(LinkedListEntry_t *));	/* Copy it */
						}
					}
					
					/* get ready to sort back to the other array */
					
					size <<= 1;		/* Double the entry size */
					++sort;			/* Increase the shift size */
					{
						LinkedListEntry_t **temp;
						temp = WorkPtr;				/* Swap the pointers */
						WorkPtr = unsorted;
						unsorted = temp;
					}
				} while (size<i);
			}


		/* Now that I have the sorted list, Let's create the */
		/* new linked list */
			
			{
				LinkedListEntry_t *EntryPtr2;
				LinkedListEntry_t *Prev;
				LinkedListEntry_t *Next;
				Word i3;
				
				EntryPtr2 = WorkPtr[0];			/* Get the new root pointer */
				++WorkPtr;
				Input->First = EntryPtr2;		/* Set as the first one */
				i3 = Input->Count-1;			/* Traverse until the final link */
				Prev = 0;						/* Zap the previous link */
				do {
					Next = WorkPtr[0];
					++WorkPtr;
					EntryPtr2->Next = Next;		/* Store the links */
					EntryPtr2->Prev = Prev;
					Prev = EntryPtr2;			/* Follow the chains */
					EntryPtr2 = Next;			/* Next one */
				} while (--i3);					/* All done? */
				EntryPtr2->Next = 0;				/* The final link */
				EntryPtr2->Prev = Prev;
				Input->Last = EntryPtr2;			/* Save the ending link */
			}
		}
		if (ArrayPtr!=Internal) {
			DeallocAPointer(ArrayPtr);		/* Dispose of the linked list flattened data */
		}
	}
}
Ejemplo n.º 18
0
int BURGERCALL vorbis_analysis_headerout(vorbis_dsp_state *v,
			      vorbis_comment *vc,
			      ogg_packet *op,
			      ogg_packet *op_comm,
			      ogg_packet *op_code){
  int ret=OV_EIMPL;
  vorbis_info *vi=v->vi;
  oggpack_buffer opb;
  backend_lookup_state *b=static_cast<backend_lookup_state *>(v->backend_state);

  if(!b){
    ret=OV_EFAULT;
    goto err_out;
  }

  /* first header packet **********************************************/

  oggpack_writeinit(&opb);
  if(_vorbis_pack_info(&opb,vi))goto err_out;

  /* build the packet */
  if(b->header)DeallocAPointer(b->header);
  b->header=static_cast<Word8 *>(AllocAPointer(oggpack_bytes(&opb)));
  FastMemCpy(b->header,opb.buffer,oggpack_bytes(&opb));
  op->packet=b->header;
  op->bytes=oggpack_bytes(&opb);
  op->b_o_s=1;
  op->e_o_s=0;
  op->granulepos=0;

  /* second header packet (comments) **********************************/

  oggpack_reset(&opb);
  if(_vorbis_pack_comment(&opb,vc))goto err_out;

  if(b->header1)DeallocAPointer(b->header1);
  b->header1=static_cast<Word8 *>(AllocAPointer(oggpack_bytes(&opb)));
  FastMemCpy(b->header1,opb.buffer,oggpack_bytes(&opb));
  op_comm->packet=b->header1;
  op_comm->bytes=oggpack_bytes(&opb);
  op_comm->b_o_s=0;
  op_comm->e_o_s=0;
  op_comm->granulepos=0;

  /* third header packet (modes/codebooks) ****************************/

  oggpack_reset(&opb);
  if(_vorbis_pack_books(&opb,vi))goto err_out;

  if(b->header2)DeallocAPointer(b->header2);
  b->header2=static_cast<Word8 *>(AllocAPointer(oggpack_bytes(&opb)));
  FastMemCpy(b->header2,opb.buffer,oggpack_bytes(&opb));
  op_code->packet=b->header2;
  op_code->bytes=oggpack_bytes(&opb);
  op_code->b_o_s=0;
  op_code->e_o_s=0;
  op_code->granulepos=0;

  oggpack_writeclear(&opb);
  return(0);
 err_out:
  oggpack_writeclear(&opb);
  FastMemSet(op,0,sizeof(*op));
  FastMemSet(op_comm,0,sizeof(*op_comm));
  FastMemSet(op_code,0,sizeof(*op_code));

  if(b->header)DeallocAPointer(b->header);
  if(b->header1)DeallocAPointer(b->header1);
  if(b->header2)DeallocAPointer(b->header2);
  b->header=NULL;
  b->header1=NULL;
  b->header2=NULL;
  return(ret);
}
Ejemplo n.º 19
0
void BURGERCALL LinkedListEntryDeallocProc(LinkedListEntry_t *Input)
{
	DeallocAPointer(Input->Data);
	DeallocAPointer(Input);
}