Skip to content

Commit 4d2ee85

Browse files
authored
Merge pull request #15 from fitzgen/fix-warnings-and-incorrect-size-in-from-raw-parts
Fix warnings and incorrect size in from raw parts
2 parents 3a7cdab + 0f47216 commit 4d2ee85

File tree

4 files changed

+7
-8
lines changed

4 files changed

+7
-8
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ license = "Apache-2.0/MIT"
1818
name = "source-map-mappings"
1919
readme = "./README.md"
2020
repository = "https://github.com/fitzgen/source-map-mappings"
21-
version = "0.3.0"
21+
version = "0.4.0"
2222

2323
[badges.travis-ci]
2424
repository = "fitzgen/source-map-mappings"
2525

2626
[dependencies]
2727
rand = "0.4.1"
28-
vlq = "0.5"
28+
vlq = "0.5.1"
2929

3030
[dev-dependencies]
3131
quickcheck = "0.5.0"

source-map-mappings-wasm-api/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ license = "Apache-2.0/MIT"
55
name = "source-map-mappings-wasm-api"
66
readme = "../README.md"
77
repository = "https://github.com/fitzgen/source-map-mappings"
8-
version = "0.3.0"
8+
version = "0.4.0"
99

1010
[badges.travis-ci]
1111
repository = "fitzgen/source-map-mappings"
1212

1313
[dependencies]
14-
source-map-mappings = { version = "0.3.0", path = ".." }
14+
source-map-mappings = { version = "0.4.0", path = ".." }
1515

1616
[features]
1717
profiling = []

source-map-mappings-wasm-api/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,9 @@ pub extern "C" fn parse_mappings(mappings: *mut u8) -> *mut Mappings<Observer> {
215215
};
216216

217217
// Deallocate the mappings string and its two prefix words.
218+
let size_in_usizes = (size + mem::size_of::<usize>() - 1) / mem::size_of::<usize>();
218219
unsafe {
219-
Vec::<usize>::from_raw_parts(capacity_ptr, size, capacity);
220+
Vec::<usize>::from_raw_parts(capacity_ptr, size_in_usizes + 2, capacity);
220221
}
221222

222223
// Return the result, saving any errors on the side for later inspection by

src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,11 @@ pub mod sort;
5353

5454
use sort::quick_sort;
5555
use std::cmp;
56-
use std::process;
5756
use std::slice;
5857
use std::u32;
5958

6059
/// Errors that can occur during parsing.
6160
#[derive(Copy, Clone, Debug)]
62-
#[repr(C)]
6361
#[repr(u32)]
6462
pub enum Error {
6563
// NB: 0 is reserved for OK.
@@ -95,7 +93,6 @@ impl From<vlq::Error> for Error {
9593
/// When doing fuzzy searching, whether to slide the next larger or next smaller
9694
/// mapping from the queried location.
9795
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
98-
#[repr(C)]
9996
#[repr(u32)]
10097
pub enum Bias {
10198
// XXX: make sure these values always match `mozilla/source-map`'s
@@ -175,6 +172,7 @@ fn unwrap<T>(o: Option<T>) -> T {
175172
#[cfg(not(debug_assertions))]
176173
#[inline]
177174
fn unwrap<T>(o: Option<T>) -> T {
175+
use std::process;
178176
match o {
179177
Some(t) => t,
180178
None => process::abort(),

0 commit comments

Comments
 (0)