Skip to content

Commit

Permalink
DO NOT MERGE Put C types on the heap
Browse files Browse the repository at this point in the history
  • Loading branch information
elBoberido committed Mar 2, 2022
1 parent 2175604 commit 7ae50f1
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 15 deletions.
5 changes: 2 additions & 3 deletions iceoryx_binding_c/source/c_listener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,12 @@ iox_listener_t iox_listener_init(iox_listener_storage_t* self)
LogWarn() << "listener initialization skipped - null pointer provided for iox_listener_storage_t";
return nullptr;
}
auto me = new (self) Listener();
return reinterpret_cast<iox_listener_t>(me);
return new Listener();
}

void iox_listener_deinit(iox_listener_t const self)
{
self->~Listener();
delete self;
}

ENUM iox_ListenerResult iox_listener_attach_subscriber_event(iox_listener_t const self,
Expand Down
5 changes: 2 additions & 3 deletions iceoryx_binding_c/source/c_publisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ iox_pub_t iox_pub_init(iox_pub_storage_t* self,
return nullptr;
}

new (self) cpp2c_Publisher();
iox_pub_t me = reinterpret_cast<iox_pub_t>(self);
auto me = new cpp2c_Publisher();

PublisherOptions publisherOptions;

Expand Down Expand Up @@ -106,7 +105,7 @@ iox_pub_t iox_pub_init(iox_pub_storage_t* self,
void iox_pub_deinit(iox_pub_t const self)
{
self->m_portData->m_toBeDestroyed.store(true, std::memory_order_relaxed);
self->~cpp2c_Publisher();
delete self;
}

iox_AllocationResult iox_pub_loan_chunk(iox_pub_t const self, void** const userPayload, const uint32_t userPayloadSize)
Expand Down
5 changes: 2 additions & 3 deletions iceoryx_binding_c/source/c_subscriber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ iox_sub_t iox_sub_init(iox_sub_storage_t* self,
return nullptr;
}

new (self) cpp2c_Subscriber();
iox_sub_t me = reinterpret_cast<iox_sub_t>(self);
auto me = new cpp2c_Subscriber();

SubscriberOptions subscriberOptions;

Expand Down Expand Up @@ -111,7 +110,7 @@ iox_sub_t iox_sub_init(iox_sub_storage_t* self,

void iox_sub_deinit(iox_sub_t const self)
{
self->~cpp2c_Subscriber();
delete self;
}

void iox_sub_subscribe(iox_sub_t const self)
Expand Down
5 changes: 2 additions & 3 deletions iceoryx_binding_c/source/c_user_trigger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,12 @@ iox_user_trigger_t iox_user_trigger_init(iox_user_trigger_storage_t* self)
LogWarn() << "user trigger initialization skipped - null pointer provided for iox_user_trigger_storage_t";
return nullptr;
}
new (self) UserTrigger();
return reinterpret_cast<iox_user_trigger_t>(self);
return new UserTrigger;
}

void iox_user_trigger_deinit(iox_user_trigger_t const self)
{
self->~UserTrigger();
delete self;
}

void iox_user_trigger_trigger(iox_user_trigger_t const self)
Expand Down
5 changes: 2 additions & 3 deletions iceoryx_binding_c/source/c_wait_set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,12 @@ iox_ws_t iox_ws_init(iox_ws_storage_t* self)
LogWarn() << "wait set initialization skipped - null pointer provided for iox_ws_storage_t";
return nullptr;
}
new (self) cpp2c_WaitSet();
return reinterpret_cast<iox_ws_t>(self);
return new cpp2c_WaitSet();
}

void iox_ws_deinit(iox_ws_t const self)
{
self->~cpp2c_WaitSet();
delete self;
}

uint64_t iox_ws_timed_wait(iox_ws_t const self,
Expand Down

0 comments on commit 7ae50f1

Please sign in to comment.