Implement PtrToHand

This commit is contained in:
Iliyas Jorio 2021-02-22 01:25:12 +01:00
parent 31f906a66b
commit 2a4ec3b76c
2 changed files with 23 additions and 0 deletions

View File

@ -97,6 +97,26 @@ void DisposeHandle(Handle h)
blocks.Dispose(b);
}
OSErr PtrToHand(const void* srcPtr, Handle* dstHndl, Size size)
{
if (!dstHndl
|| (!srcPtr && size > 0)
|| size < 0)
{
return paramErr;
}
Handle h = NewHandle(size);
if (!h)
return memFullErr;
*dstHndl = h;
memcpy(*h, srcPtr, size);
return noErr;
}
//-----------------------------------------------------------------------------
// Memory: Ptr

View File

@ -352,6 +352,9 @@ void SetHandleSize(Handle, Size);
void DisposeHandle(Handle);
// Allocates a handle of the given size and copies the contents of srcPtr into it
OSErr PtrToHand(const void* srcPtr, Handle* dstHndl, Size size);
//-----------------------------------------------------------------------------
// Memory: Ptr