Skip to content
This repository has been archived by the owner on May 5, 2024. It is now read-only.

Commit

Permalink
feat: add malloc_struct
Browse files Browse the repository at this point in the history
  • Loading branch information
Mause committed Oct 20, 2022
1 parent 17c579c commit ee56c93
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/data_chunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl DataChunk {

Self { ptr, owned: true }
}

/// Retrieves the vector at the specified column index in the data chunk.
///
/// The pointer to the vector is valid for as long as the chunk is alive.
Expand Down
10 changes: 10 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ mod table_function;
mod value;
mod vector;

use std::mem::size_of;

pub use crate::bind_info::BindInfo;
pub use crate::connection::Connection;
pub use crate::data_chunk::DataChunk;
Expand All @@ -22,3 +24,11 @@ pub use crate::logical_type::LogicalType;
pub use crate::table_function::TableFunction;
pub use crate::value::Value;
pub use crate::vector::Vector;

use crate::duckly::duckdb_malloc;

/// # Safety
/// This function is obviously unsafe
pub unsafe fn malloc_struct<T>() -> *mut T {
duckdb_malloc(size_of::<T>() as u64).cast::<T>()
}

0 comments on commit ee56c93

Please sign in to comment.