Example #1
0
void SetHandleSize (Handle handle, size_t newSize)
{
	Ptr p;
	HANDLE hMem;


	memError = noErr;

	if (handle)
	{
		p = *handle;

		if (p)
		{
			GlobalUnlockPtr (p);
			hMem = GlobalReAlloc (GlobalPtrHandle (p), newSize, GHND);	
			if (hMem)
				p = (Ptr)GlobalLock (hMem);
			else
				p = NULL;
		}
 
		if (p)

			*handle = p;
		else

			memError = memFullErr;
	}

	else

		memError = memWZErr;

}
Example #2
0
size_t WSizeBuffer(LPSTR ptr)
{
	HANDLE	hand;

	hand = GlobalPtrHandle(ptr);
	return GlobalSize(hand);
}
Example #3
0
void FreeUp( LPVOID lpMemory )
/************************************************************************/
{
HGLOBAL hMem;

if ( !lpMemory )
	return;

if ( !(hMem = GlobalPtrHandle(lpMemory)) )
	return;

#ifdef _DEBUG_MEMORY
	TableRemove( lpMemory );
#endif

GlobalUnlock(hMem);
GlobalFree(hMem);
}
Example #4
0
void TableAdd( LPTR lpMemory )
/************************************************************************/
{
int i;

for ( i=0; i<100; i++ )
	{
	if ( !at[i].lp )
		break;
	}

if ( i >= 100 )
	return;

at[i].lp = lpMemory;
at[i].dwSize = GlobalSize(GlobalPtrHandle(lpMemory));

Debug( "Add slot %d\r", i );

// Print the table
TablePrint();
}
Example #5
0
size_t GetHandleSize(Handle handle)
{
	Ptr p;
	HANDLE h;

	memError = noErr;

	if (handle)
		{
		p = *handle;

		h = GlobalPtrHandle (p);

		if (h)

			return GlobalSize (h);
		}

	memError = nilHandleErr;

	return 0L;

}
Example #6
0
LPTR AllocExtend( LPTR lpMemory, long lCount )
/************************************************************************/
{
LPTR lpNewMemory;
HGLOBAL hMem, hNewMem;

// Round up to the next 16 byte boundary
lCount++; // Protection against a possible C7.0 bug
lCount = ((lCount + 15) / 16) * 16;

if ( !(hMem = GlobalPtrHandle(lpMemory)) )
	return(NULL);
if ( !(hNewMem = GlobalReAlloc(hMem, lCount, GMEM_MOVEABLE)) )
	return(NULL);

if ( !(lpNewMemory = (LPTR)GlobalLock(hNewMem)) )
	GlobalFree(hNewMem);

#ifdef _DEBUG_MEMORY
	TableAdd( lpMemory );
#endif

return( lpNewMemory );
}
Example #7
0
HANDLE HandFromPtr(LPSTR ptr)
{
    return GlobalPtrHandle(ptr);
}
Example #8
0
void FreeSegment(char *s)
{
  GlobalUnlockPtr(s);
  GlobalFree(GlobalPtrHandle(s));
}