Exemplo n.º 1
0
/***********************************************************************
 * main event loop; loops until appStopEvent is caught or
 * QuitApp is set
 ***********************************************************************/
static void
AppEventLoop(void)
{
  UInt16 error;
  EventType event;


  do {
    EvtGetEvent(&event, evtWaitForever);


    if (! SysHandleEvent(&event))
      if (! MenuHandleEvent(0, &event, &error))
	if (! AppHandleEvent(&event))
	  FrmDispatchEvent(&event);

    // Check the heaps after each event
#if EMULATION_LEVEL != EMULATION_NONE
    MemHeapCheck(0);
    MemHeapCheck(1);
#endif
  } while (event.eType != appStopEvent);

}
Exemplo n.º 2
0
void* DebugNew( size_t size, bool arrayType, const char* name, int line )
{
	void* mem = 0;
	if ( size == 0 )
		size = 1;

	GLASSERT( size );
	size_t allocateSize = size + sizeof(MemCheckHead) + sizeof(MemCheckTail);
	mem = malloc( allocateSize );

	MemCheckHead* head = (MemCheckHead*)(mem);
	MemCheckTail* tail = (MemCheckTail*)((unsigned char*)mem+sizeof(MemCheckHead)+size);
	void* body = (void*)((unsigned char*)mem+sizeof(MemCheckHead));
	GLASSERT( body );

	head->size = size;
	head->arrayType = arrayType;
	head->id = idPool++;
	head->name = name;
	head->line = line;

	head->magic = MEM_MAGIC0;
	tail->magic = MEM_MAGIC1;
	head->prev = head->next = 0;

	if ( checking )
	{
		++memNewCount;
		memTotal += size;
		if ( memTotal > memWatermark )
			memWatermark = memTotal;

		if ( root )
			root->prev = head;
		head->next = root;
		head->prev = 0;
		root = head;
	}

	// #BREAKHERE
	//if ( head->id == 59828 )
	//	int debug = 1;

#ifdef GRINLIZ_DEBUG_MEM_DEEP
	MemHeapCheck();
#endif
	return body;
}
Exemplo n.º 3
0
void DebugDelete( void* mem, bool arrayType )
{
#ifdef GRINLIZ_DEBUG_MEM_DEEP
	MemHeapCheck();
#endif
	if ( mem ) {
		MemCheckHead* head = (MemCheckHead*)((unsigned char*)mem-sizeof(MemCheckHead));
		MemCheckTail* tail = (MemCheckTail*)((unsigned char*)mem+head->size);

		// For debugging, so if the asserts do fire, we still have a copy of the values.
		MemCheckHead aHead = *head;
		MemCheckTail aTail = *tail;

		GLASSERT( head->magic == MEM_MAGIC0 );
		GLASSERT( tail->magic == MEM_MAGIC1 );
		
		// A bug in the OpenGL driver on Mac fires this.
		#if !defined( __APPLE__ )
		GLASSERT( head->arrayType == arrayType );
		#endif

		if ( head->prev )
			head->prev->next = head->next;
		else
			root = head->next;

		if ( head->next )
			head->next->prev = head->prev;
		
		if ( checking )
		{
			++memDeleteCount;
			memTotal -= head->size;
		}
		head->magic = MEM_DELETED0;
		tail->magic = MEM_DELETED1;
		free(head);
	}
}