summaryrefslogtreecommitdiff
path: root/rust/src/databuffer.rs
diff options
context:
space:
mode:
Diffstat (limited to 'rust/src/databuffer.rs')
-rw-r--r--rust/src/databuffer.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/rust/src/databuffer.rs b/rust/src/databuffer.rs
index 65003711..e8bf32c9 100644
--- a/rust/src/databuffer.rs
+++ b/rust/src/databuffer.rs
@@ -27,7 +27,7 @@ impl DataBuffer {
}
pub fn get_data(&self) -> &[u8] {
- if self.0 == ptr::null_mut() {
+ if self.0.is_null() {
// TODO : Change the default value and remove this
return &[];
}
@@ -43,6 +43,10 @@ impl DataBuffer {
unsafe { BNGetDataBufferLength(self.0) }
}
+ pub fn is_empty(&self) -> bool {
+ unsafe { BNGetDataBufferLength(self.0) == 0 }
+ }
+
// pub fn new(data: ?, len: usize) -> Result<Self> {
// let read_buffer = unsafe { BNCreateDataBuffer(data, len) };
// if read_buffer.is_null() {
@@ -62,7 +66,7 @@ impl Default for DataBuffer {
impl Drop for DataBuffer {
fn drop(&mut self) {
- if self.0 != ptr::null_mut() {
+ if !self.0.is_null() {
unsafe {
BNFreeDataBuffer(self.0);
}