Skip to content

Commit

Permalink
debug windows build
Browse files Browse the repository at this point in the history
  • Loading branch information
eileencodes committed Feb 6, 2024
1 parent a736bef commit b8cb050
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/util/pm_string.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,14 @@ pm_string_mapped_init(pm_string_t *string, const char *filepath) {
HANDLE file = CreateFile(filepath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);

if (file == INVALID_HANDLE_VALUE) {
errno = map_errno(GetLastError());
return errno;
}

// Get the file size.
DWORD file_size = GetFileSize(file, NULL);
if (file_size == INVALID_FILE_SIZE) {
fprintf(stderr, "invalid file size\n");
CloseHandle(file);
return errno;
}
Expand All @@ -79,6 +81,7 @@ pm_string_mapped_init(pm_string_t *string, const char *filepath) {
// the source to a constant empty string and return.
if (file_size == 0) {
CloseHandle(file);
fprintf(stderr, "close handle\n");
const uint8_t source[] = "";
*string = (pm_string_t) { .type = PM_STRING_CONSTANT, .source = source, .length = 0 };
return 0;
Expand All @@ -88,6 +91,7 @@ pm_string_mapped_init(pm_string_t *string, const char *filepath) {
HANDLE mapping = CreateFileMapping(file, NULL, PAGE_READONLY, 0, 0, NULL);
if (mapping == NULL) {
CloseHandle(file);
fprintf(stderr, "close handle, mapping is null\n");
return errno;
}

Expand All @@ -97,6 +101,7 @@ pm_string_mapped_init(pm_string_t *string, const char *filepath) {
CloseHandle(file);

if (source == NULL) {
fprintf(stderr, "source was null\n");
return errno;
}

Expand Down

0 comments on commit b8cb050

Please sign in to comment.