xcb: use a more efficient unique_ptr instantiation
Wrap std::free() in a function object, to avoid having to carry around state (the function pointer) inside unique_ptr objects. This shrinks unique_ptrs back to sizeof(void*). Change-Id: I32a711192c5485dc04e3b36a1ddabf02d1e9d4f9 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>bb10
parent
6fed5cf4e2
commit
28fbd13e22
|
|
@ -757,16 +757,18 @@ private:
|
|||
|
||||
#define Q_XCB_REPLY_CONNECTION_ARG(connection, ...) connection
|
||||
|
||||
struct QStdFreeDeleter {
|
||||
void operator()(void *p) const Q_DECL_NOTHROW { return std::free(p); }
|
||||
};
|
||||
|
||||
#define Q_XCB_REPLY(call, ...) \
|
||||
std::unique_ptr<call##_reply_t, decltype(std::free) *>( \
|
||||
call##_reply(Q_XCB_REPLY_CONNECTION_ARG(__VA_ARGS__), call(__VA_ARGS__), nullptr), \
|
||||
std::free \
|
||||
std::unique_ptr<call##_reply_t, QStdFreeDeleter>( \
|
||||
call##_reply(Q_XCB_REPLY_CONNECTION_ARG(__VA_ARGS__), call(__VA_ARGS__), nullptr) \
|
||||
)
|
||||
|
||||
#define Q_XCB_REPLY_UNCHECKED(call, ...) \
|
||||
std::unique_ptr<call##_reply_t, decltype(std::free) *>( \
|
||||
call##_reply(Q_XCB_REPLY_CONNECTION_ARG(__VA_ARGS__), call##_unchecked(__VA_ARGS__), nullptr), \
|
||||
std::free \
|
||||
std::unique_ptr<call##_reply_t, QStdFreeDeleter>( \
|
||||
call##_reply(Q_XCB_REPLY_CONNECTION_ARG(__VA_ARGS__), call##_unchecked(__VA_ARGS__), nullptr) \
|
||||
)
|
||||
|
||||
template <typename T>
|
||||
|
|
|
|||
Loading…
Reference in New Issue