Skip to content

Commit

Permalink
Avoid realloc when creating C-style strings
Browse files Browse the repository at this point in the history
  • Loading branch information
mlowicki committed Aug 21, 2024
1 parent d739960 commit b2e5e07
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ impl OwnedHeaders {
where
V: ToBytes + ?Sized,
{
let name_cstring = CString::new(header.key.to_owned()).unwrap();
let name_cstring = CString::new(header.key).unwrap();
let (value_ptr, value_len) = match header.value {
None => (ptr::null_mut(), 0),
Some(value) => {
Expand Down
2 changes: 1 addition & 1 deletion src/producer/base_producer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ where
}
let (payload_ptr, payload_len) = as_bytes(record.payload);
let (key_ptr, key_len) = as_bytes(record.key);
let topic_cstring = CString::new(record.topic.to_owned()).unwrap();
let topic_cstring = CString::new(record.topic).unwrap();
let opaque_ptr = record.delivery_opaque.into_ptr();
let produce_error = unsafe {
rdsys::rd_kafka_producev(
Expand Down

0 comments on commit b2e5e07

Please sign in to comment.