Skip to content

Commit f57c0c4

Browse files
committed
Fix the build by avoiding by-value struct arguments
1 parent b14726b commit f57c0c4

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/lib.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ typedef struct {
55
uint32_t column;
66
} Point;
77

8-
Point add_points_in_c(Point a, Point b) {
9-
if (b.line > 0) {
10-
return (Point) {a.line + b.line, b.column};
8+
Point add_points_in_c(const Point *a, const Point *b) {
9+
if (b->line > 0) {
10+
return (Point) {a->line + b->line, b->column};
1111
} else {
12-
return (Point) {a.line, a.column + b.column};
12+
return (Point) {a->line, a->column + b->column};
1313
}
1414
}

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ pub struct Point {
88
}
99

1010
extern "C" {
11-
fn add_points_in_c(a: Point, b: Point) -> Point;
11+
fn add_points_in_c(a: *const Point, b: *const Point) -> Point;
1212
}
1313

1414
#[wasm_bindgen]
1515
pub fn add_points_in_rust(a: Point, b: Point) -> Point {
16-
unsafe { add_points_in_c(a, b) }
16+
unsafe { add_points_in_c(&a as *const Point, &b as *const Point) }
1717
}
1818

1919
#[wasm_bindgen]

0 commit comments

Comments
 (0)