Skip to content

Commit

Permalink
closes 105. cleanup MemoryPointer (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
smedegaard authored Nov 25, 2024
1 parent c95a68a commit f57d39e
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions src/types/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ impl<T> MemoryPointer<T> {

(pointer, code).to_result()
}

/// Returns the raw memory pointer.
///
/// Note: This pointer cannot be directly dereferenced from CPU code.
pub fn as_ptr(&self) -> *mut T {
self.ptr
}

/// Returns the size in bytes of the allocated memory
pub fn size(&self) -> usize {
self.size
}
}

// The Drop trait does not return anything by design
Expand All @@ -49,20 +61,6 @@ impl<T> Drop for MemoryPointer<T> {
}
}

impl<T> MemoryPointer<T> {
/// Returns the raw memory pointer.
///
/// Note: This pointer cannot be directly dereferenced from CPU code.
pub fn as_ptr(&self) -> *mut T {
self.ptr
}

/// Returns the size in bytes of the allocated memory
pub fn size(&self) -> usize {
self.size
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down

0 comments on commit f57d39e

Please sign in to comment.