diff --git a/src/platform/waiter_linux.h b/src/platform/waiter_linux.h index 3bee40d..ac8b1c2 100644 --- a/src/platform/waiter_linux.h +++ b/src/platform/waiter_linux.h @@ -252,7 +252,7 @@ public: } // calc a new wait-id & construct event object event evt { ipc::detail::calc_unique_id() }; - auto ids = static_cast(mem::alloc(sizeof(std::size_t[size]))); + auto ids = static_cast(mem::alloc(sizeof(std::size_t) * size)); for (std::size_t i = 0; i < size; ++i) { ids[i] = std::get<0>(all[i])->push_event(evt); } @@ -260,7 +260,7 @@ public: for (std::size_t i = 0; i < size; ++i) { std::get<0>(all[i])->pop_event(ids[i]); } - mem::free(ids, sizeof(std::size_t[size])); + mem::free(ids, sizeof(std::size_t) * size); }); // wait for event signal return evt.wait(); diff --git a/src/platform/waiter_win.h b/src/platform/waiter_win.h index 8e2378f..aa69d91 100644 --- a/src/platform/waiter_win.h +++ b/src/platform/waiter_win.h @@ -41,8 +41,8 @@ public: if (all == nullptr || size == 0) { return false; } - auto hs = static_cast(mem::alloc(sizeof(handle_t[size]))); - IPC_UNUSED_ auto guard = unique_ptr(hs, [size](void* p) { mem::free(p, sizeof(handle_t[size])); }); + auto hs = static_cast(mem::alloc(sizeof(handle_t) * size)); + IPC_UNUSED_ auto guard = unique_ptr(hs, [size](void* p) { mem::free(p, sizeof(handle_t) * size); }); std::size_t i = 0; for (; i < size; ++i) { auto& info = all[i]; @@ -52,7 +52,7 @@ public: hs[i] = std::get<1>(all[i]); } std::atomic_thread_fence(std::memory_order_release); - return ::WaitForMultipleObjects(hs, i, FALSE, INFINITE) != WAIT_FAILED; + return ::WaitForMultipleObjects(static_cast(i), hs, FALSE, INFINITE) != WAIT_FAILED; } bool wait(handle_t h) { diff --git a/src/platform/waiter_wrapper.h b/src/platform/waiter_wrapper.h index 6397282..050b897 100644 --- a/src/platform/waiter_wrapper.h +++ b/src/platform/waiter_wrapper.h @@ -67,8 +67,8 @@ public: return false; } using tp_t = decltype(std::declval().to_w_info()); - auto hs = static_cast(mem::alloc(sizeof(tp_t[size]))); - IPC_UNUSED_ auto guard = unique_ptr(hs, [size](void* p) { mem::free(p, sizeof(tp_t[size])); }); + auto hs = static_cast(mem::alloc(sizeof(tp_t) * size)); + IPC_UNUSED_ auto guard = unique_ptr(hs, [size](void* p) { mem::free(p, sizeof(tp_t) * size); }); std::size_t i = 0; for (; i < size; ++i) { auto& w = all[i];