Increase sigslot internal pointer representation to 24 bytes.

Bug: webrtc:12836
Change-Id: Ic3bfa7fd637d27d580e6921afadb364bbba2fe03
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/228425
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Björn Terelius <terelius@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34717}
This commit is contained in:
Bjorn Terelius
2021-08-11 10:06:32 +02:00
committed by WebRTC LUCI CQ
parent 53d4be223b
commit 10ed5f98b9

View File

@ -290,9 +290,13 @@ class _opaque_connection {
emit_t pemit;
has_slots_interface* pdest;
// Pointers to member functions may be up to 16 bytes for virtual classes,
// so make sure we have enough space to store it.
// Pointers to member functions may be up to 16 bytes (24 bytes for MSVC)
// for virtual classes, so make sure we have enough space to store it.
#if defined(_MSC_VER) && !defined(__clang__)
unsigned char pmethod[24];
#else
unsigned char pmethod[16];
#endif
public:
template <typename DestT, typename... Args>
@ -332,6 +336,8 @@ class _opaque_connection {
static void emitter(const _opaque_connection* self, Args... args) {
typedef void (DestT::*pm_t)(Args...);
pm_t pm;
static_assert(sizeof(pm_t) <= sizeof(pmethod),
"Size of slot function pointer too large.");
std::memcpy(&pm, self->pmethod, sizeof(pm_t));
(static_cast<DestT*>(self->pdest)->*(pm))(args...);
}