AK: Add Error::from_windows_error(void)

Also slightly improve Error::from_windows_error(int)
This commit is contained in:
stasoid 2024-12-08 22:00:56 +05:00 committed by Andrew Kaster
commit 870cce9d11
Notes: github-actions[bot] 2025-02-06 02:28:57 +00:00
5 changed files with 40 additions and 34 deletions

View file

@ -30,7 +30,7 @@ ErrorOr<NonnullRefPtr<AnonymousBufferImpl>> AnonymousBufferImpl::create(size_t s
{
HANDLE map_handle = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, size >> 31 >> 1, size & 0xFFFFFFFF, NULL);
if (!map_handle)
return Error::from_windows_error(GetLastError());
return Error::from_windows_error();
return create((int)(intptr_t)map_handle, size);
}
@ -39,7 +39,7 @@ ErrorOr<NonnullRefPtr<AnonymousBufferImpl>> AnonymousBufferImpl::create(int fd,
{
void* ptr = MapViewOfFile((HANDLE)(intptr_t)fd, FILE_MAP_ALL_ACCESS, 0, 0, size);
if (!ptr)
return Error::from_windows_error(GetLastError());
return Error::from_windows_error();
return adopt_nonnull_ref_or_enomem(new (nothrow) AnonymousBufferImpl(fd, size, ptr));
}