diff options
| author | gingerBill <bill@gingerbill.org> | 2023-01-02 20:55:49 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2023-01-02 20:55:49 +0000 |
| commit | f16d8e77b3f9b3ddf82e97672ca38dc19264eb5e (patch) | |
| tree | 27fed0c1f07ef5cd6f22eb2a91c84f1984d85d3a /src/build_settings.cpp | |
| parent | 5b335bb88c9045961a2a20d021ec5f4b5acf96ce (diff) | |
Narrow `fullpath_mutex` usage
Diffstat (limited to 'src/build_settings.cpp')
| -rw-r--r-- | src/build_settings.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/build_settings.cpp b/src/build_settings.cpp index f59b5c0f7..04d1ada93 100644 --- a/src/build_settings.cpp +++ b/src/build_settings.cpp @@ -937,16 +937,20 @@ gb_global BlockingMutex fullpath_mutex; #if defined(GB_SYSTEM_WINDOWS) gb_internal String path_to_fullpath(gbAllocator a, String s) { String result = {}; - mutex_lock(&fullpath_mutex); - defer (mutex_unlock(&fullpath_mutex)); String16 string16 = string_to_string16(heap_allocator(), s); defer (gb_free(heap_allocator(), string16.text)); - DWORD len = GetFullPathNameW(&string16[0], 0, nullptr, nullptr); + DWORD len; + + mutex_lock(&fullpath_mutex); + + len = GetFullPathNameW(&string16[0], 0, nullptr, nullptr); if (len != 0) { wchar_t *text = gb_alloc_array(permanent_allocator(), wchar_t, len+1); GetFullPathNameW(&string16[0], len, text, nullptr); + mutex_unlock(&fullpath_mutex); + text[len] = 0; result = string16_to_string(a, make_string16(text, len)); result = string_trim_whitespace(result); @@ -957,6 +961,8 @@ gb_internal String path_to_fullpath(gbAllocator a, String s) { result.text[i] = '/'; } } + } else { + mutex_unlock(&fullpath_mutex); } return result; |