Skip to content

Commit

Permalink
Merge pull request #712 from mlowicki/mlowicki/cstring_realloc_optim
Browse files Browse the repository at this point in the history
Avoid realloc when creating C-style strings
  • Loading branch information
davidblewett authored Aug 23, 2024
2 parents d739960 + b2e5e07 commit 964d5b8
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 964d5b8

Please sign in to comment.