Skip to content

Commit

Permalink
Add Context::from_arc_dwarf (#327)
Browse files Browse the repository at this point in the history
The context was already using `Arc` internally, so this allows the
caller to use the same `Dwarf` for other purposes.
  • Loading branch information
philipc authored Sep 11, 2024
1 parent 48f4734 commit 5d10d81
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,12 @@ impl<R: gimli::Reader> Context<R> {
/// Construct a new `Context` from an existing [`gimli::Dwarf`] object.
#[inline]
pub fn from_dwarf(sections: gimli::Dwarf<R>) -> Result<Context<R>, Error> {
let sections = Arc::new(sections);
Self::from_arc_dwarf(Arc::new(sections))
}

/// Construct a new `Context` from an existing [`gimli::Dwarf`] object.
#[inline]
pub fn from_arc_dwarf(sections: Arc<gimli::Dwarf<R>>) -> Result<Context<R>, Error> {
let units = ResUnits::parse(&sections)?;
let sup_units = if let Some(sup) = sections.sup.as_ref() {
SupUnits::parse(sup)?
Expand Down

0 comments on commit 5d10d81

Please sign in to comment.