diff options
| author | KyleMiles <krm504@nyu.edu> | 2023-01-05 17:29:14 -0500 |
|---|---|---|
| committer | KyleMiles <krm504@nyu.edu> | 2023-01-06 16:29:58 -0500 |
| commit | a154e45cce79b0c2264c1e1cd37a3d1bf5bc6154 (patch) | |
| tree | 11f436b720edfdf37819e9e83e7131d220687074 /rust/src/databuffer.rs | |
| parent | 52edc39a7081fd6662e14fbcd473adabbbc36c7a (diff) | |
Rust API: Lots and lots of clippy changes
Diffstat (limited to 'rust/src/databuffer.rs')
| -rw-r--r-- | rust/src/databuffer.rs | 8 |
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); } |
