Skip to content

Commit 2e547ac

Browse files
committed
Retain core string for section strings in Rust API
1 parent 41557b0 commit 2e547ac

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

rust/src/binary_view.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -871,23 +871,23 @@ pub trait BinaryViewExt: BinaryViewBase {
871871
section.create(self.as_ref());
872872
}
873873

874-
fn remove_auto_section(&self, name: &str) {
874+
fn remove_auto_section(&self, name: impl IntoCStr) {
875875
let raw_name = name.to_cstr();
876876
let raw_name_ptr = raw_name.as_ptr();
877877
unsafe {
878878
BNRemoveAutoSection(self.as_ref().handle, raw_name_ptr);
879879
}
880880
}
881881

882-
fn remove_user_section(&self, name: &str) {
882+
fn remove_user_section(&self, name: impl IntoCStr) {
883883
let raw_name = name.to_cstr();
884884
let raw_name_ptr = raw_name.as_ptr();
885885
unsafe {
886886
BNRemoveUserSection(self.as_ref().handle, raw_name_ptr);
887887
}
888888
}
889889

890-
fn section_by_name(&self, name: &str) -> Option<Ref<Section>> {
890+
fn section_by_name(&self, name: impl IntoCStr) -> Option<Ref<Section>> {
891891
unsafe {
892892
let raw_name = name.to_cstr();
893893
let name_ptr = raw_name.as_ptr();

rust/src/section.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,12 @@ impl Section {
121121
unsafe { BNSectionGetSemantics(self.handle).into() }
122122
}
123123

124-
pub fn linked_section(&self) -> String {
125-
unsafe { BnString::into_string(BNSectionGetLinkedSection(self.handle)) }
124+
pub fn linked_section(&self) -> BnString {
125+
unsafe { BnString::from_raw(BNSectionGetLinkedSection(self.handle)) }
126126
}
127127

128-
pub fn info_section(&self) -> String {
129-
unsafe { BnString::into_string(BNSectionGetInfoSection(self.handle)) }
128+
pub fn info_section(&self) -> BnString {
129+
unsafe { BnString::from_raw(BNSectionGetInfoSection(self.handle)) }
130130
}
131131

132132
pub fn info_data(&self) -> u64 {

0 commit comments

Comments
 (0)