|
14 | 14 | #include "libipc/ipc.h"
|
15 | 15 | #include "libipc/def.h"
|
16 | 16 | #include "libipc/shm.h"
|
17 |
| -#include "libipc/pool_alloc.h" |
18 | 17 | #include "libipc/queue.h"
|
19 | 18 | #include "libipc/policy.h"
|
20 | 19 | #include "libipc/rw_lock.h"
|
|
26 | 25 | #include "libipc/utility/utility.h"
|
27 | 26 |
|
28 | 27 | #include "libipc/mem/resource.h"
|
| 28 | +#include "libipc/mem/new.h" |
29 | 29 | #include "libipc/platform/detail.h"
|
30 | 30 | #include "libipc/circ/elem_array.h"
|
31 | 31 |
|
@@ -64,10 +64,15 @@ struct msg_t : msg_t<0, AlignSize> {
|
64 | 64 | };
|
65 | 65 |
|
66 | 66 | template <typename T>
|
67 |
| -ipc::buff_t make_cache(T& data, std::size_t size) { |
68 |
| - auto ptr = ipc::mem::alloc(size); |
| 67 | +ipc::buff_t make_cache(T &data, std::size_t size) { |
| 68 | + auto *ptr = ipc::mem::$new<void>(size); |
69 | 69 | std::memcpy(ptr, &data, (ipc::detail::min)(sizeof(data), size));
|
70 |
| - return { ptr, size, ipc::mem::free }; |
| 70 | + return { |
| 71 | + ptr, size, |
| 72 | + [](void *p, std::size_t) noexcept { |
| 73 | + ipc::mem::$delete(p); |
| 74 | + } |
| 75 | + }; |
71 | 76 | }
|
72 | 77 |
|
73 | 78 | acc_t *cc_acc(std::string const &pref) {
|
@@ -259,8 +264,8 @@ chunk_info_t *chunk_storage_info(conn_info_head *inf, std::size_t chunk_size) {
|
259 | 264 | guard.unlock();
|
260 | 265 | LIBIPC_UNUSED std::lock_guard<ipc::rw_lock> guard {lock};
|
261 | 266 | it = storages.emplace(chunk_size, chunk_handle_ptr_t{
|
262 |
| - ipc::mem::alloc<chunk_handle_t>(), [](chunk_handle_t *p) { |
263 |
| - ipc::mem::destruct(p); |
| 267 | + ipc::mem::$new<chunk_handle_t>(), [](chunk_handle_t *p) { |
| 268 | + ipc::mem::$delete(p); |
264 | 269 | }}).first;
|
265 | 270 | }
|
266 | 271 | }
|
@@ -447,7 +452,7 @@ constexpr static queue_t* queue_of(ipc::handle_t h) noexcept {
|
447 | 452 | static bool connect(ipc::handle_t * ph, ipc::prefix pref, char const * name, bool start_to_recv) {
|
448 | 453 | assert(ph != nullptr);
|
449 | 454 | if (*ph == nullptr) {
|
450 |
| - *ph = ipc::mem::alloc<conn_info_t>(pref.str, name); |
| 455 | + *ph = ipc::mem::$new<conn_info_t>(pref.str, name); |
451 | 456 | }
|
452 | 457 | return reconnect(ph, start_to_recv);
|
453 | 458 | }
|
@@ -490,7 +495,7 @@ static bool reconnect(ipc::handle_t * ph, bool start_to_recv) {
|
490 | 495 | }
|
491 | 496 |
|
492 | 497 | static void destroy(ipc::handle_t h) noexcept {
|
493 |
| - ipc::mem::free(info_of(h)); |
| 498 | + ipc::mem::$delete(info_of(h)); |
494 | 499 | }
|
495 | 500 |
|
496 | 501 | static std::size_t recv_count(ipc::handle_t h) noexcept {
|
@@ -654,20 +659,20 @@ static ipc::buff_t recv(ipc::handle_t h, std::uint64_t tm) {
|
654 | 659 | conn_info_t * inf;
|
655 | 660 | ipc::circ::cc_t curr_conns;
|
656 | 661 | ipc::circ::cc_t conn_id;
|
657 |
| - } *r_info = ipc::mem::alloc<recycle_t>(recycle_t{ |
| 662 | + } *r_info = ipc::mem::$new<recycle_t>(recycle_t{ |
658 | 663 | buf_id,
|
659 | 664 | inf,
|
660 | 665 | que->elems()->connections(std::memory_order_relaxed),
|
661 | 666 | que->connected_id()
|
662 | 667 | });
|
663 | 668 | if (r_info == nullptr) {
|
664 |
| - ipc::log("fail: ipc::mem::alloc<recycle_t>.\n"); |
| 669 | + ipc::log("fail: ipc::mem::$new<recycle_t>.\n"); |
665 | 670 | return ipc::buff_t{buf, msg_size}; // no recycle
|
666 | 671 | } else {
|
667 | 672 | return ipc::buff_t{buf, msg_size, [](void* p_info, std::size_t size) {
|
668 | 673 | auto r_info = static_cast<recycle_t *>(p_info);
|
669 | 674 | LIBIPC_UNUSED auto finally = ipc::guard([r_info] {
|
670 |
| - ipc::mem::free(r_info); |
| 675 | + ipc::mem::$delete(r_info); |
671 | 676 | });
|
672 | 677 | recycle_storage<flag_t>(r_info->storage_id,
|
673 | 678 | r_info->inf,
|
|
0 commit comments