Skip to content

Commit

Permalink
Remove unnecessary malloc/memcpy/free.
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Lalancette <[email protected]>
  • Loading branch information
clalancette committed Feb 9, 2024
1 parent cdc39af commit c8651af
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions rmw_zenoh_cpp/src/rmw_zenoh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2055,13 +2055,10 @@ static z_owned_bytes_map_t create_map_and_set_sequence_num(

z_bytes_t guid_bytes;
guid_bytes.len = RMW_GID_STORAGE_SIZE;
guid_bytes.start = static_cast<uint8_t *>(malloc(RMW_GID_STORAGE_SIZE));
memcpy(static_cast<void *>(const_cast<uint8_t *>(guid_bytes.start)), guid, RMW_GID_STORAGE_SIZE);
guid_bytes.start = guid;

z_bytes_map_insert_by_copy(&map, z_bytes_new("client_guid"), guid_bytes);

free(const_cast<uint8_t *>(guid_bytes.start));

free_attachment_map.cancel();

return map;
Expand Down

0 comments on commit c8651af

Please sign in to comment.