Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(document): enforce drop order on DocumentInner #21

Merged
merged 1 commit into from
Aug 5, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// See comments in the Table struct for details about safety.
use intrusive_collections::{LinkedList, LinkedListLink, UnsafeRef};
use std::str::FromStr;
use std::mem::size_of;
use std::mem;
use typed_arena::Arena;
use table::{Header, HeaderKind, Table, TableChild};
use decor::{InternalString, Repr};
Expand Down Expand Up @@ -61,7 +61,7 @@ impl Document {
pub fn new() -> Self {
let list = LinkedList::new(intrusive::TableAdapter::new());
// reserve space for 10 tables
let arena = Arena::with_capacity(size_of::<Table>() * 10);
let arena = Arena::with_capacity(mem::size_of::<Table>() * 10);
let inner = DocumentInner::new(arena, list);
let mut doc = Box::new(inner);
let header = Header {
Expand Down Expand Up @@ -131,6 +131,12 @@ impl DocumentInner {
}
}

impl Drop for DocumentInner {
fn drop(&mut self) {
self.list.clear();
}
}

impl FromStr for Document {
type Err = parser::Error;

Expand Down