Add comments
This commit is contained in:
parent
42e4956fb9
commit
893ef857d7
@ -318,6 +318,8 @@ B mmap_file(B path) {
|
||||
thrM("failed to mmap file");
|
||||
}
|
||||
#else
|
||||
// see https://learn.microsoft.com/en-us/windows/win32/memory/creating-a-view-within-a-file
|
||||
|
||||
HANDLE hFile = CreateFileA(
|
||||
p, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, NULL,
|
||||
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
|
||||
@ -1,11 +1,13 @@
|
||||
#include <windows.h>
|
||||
|
||||
// memory is allocated and should be freed with LocalFree()
|
||||
// for now this memory is leaked
|
||||
static char* winErrorEx(DWORD dwError) {
|
||||
char* buffer = NULL;
|
||||
DWORD dwFlags = FORMAT_MESSAGE_MAX_WIDTH_MASK
|
||||
| FORMAT_MESSAGE_ALLOCATE_BUFFER
|
||||
| FORMAT_MESSAGE_FROM_SYSTEM
|
||||
| FORMAT_MESSAGE_IGNORE_INSERTS;
|
||||
DWORD dwFlags = FORMAT_MESSAGE_MAX_WIDTH_MASK // no newlines
|
||||
| FORMAT_MESSAGE_ALLOCATE_BUFFER // allocate memory
|
||||
| FORMAT_MESSAGE_FROM_SYSTEM // get error message
|
||||
| FORMAT_MESSAGE_IGNORE_INSERTS; // no argument (NULL)
|
||||
DWORD dwResult = FormatMessageA(dwFlags, NULL, dwError, 0, (LPSTR)&buffer, 0, NULL);
|
||||
if (dwResult==0 || buffer==NULL) {
|
||||
fatal("Failed to get error message from FormatMessageA()");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user