Skip to content

Commit

Permalink
Merge pull request #642 from fdopen/complex-fix
Browse files Browse the repository at this point in the history
fix complex allocation size
  • Loading branch information
yallop authored Apr 27, 2020
2 parents c9481e3 + adce327 commit 38cc3c1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/ctypes/complex_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

static value allocate_complex_value(double r, double i)
{
value v = caml_alloc(2 * sizeof(double), Double_array_tag);
value v = caml_alloc(2 * Double_wosize, Double_array_tag);
Store_double_field(v, 0, r);
Store_double_field(v, 1, i);
return v;
Expand Down
7 changes: 6 additions & 1 deletion tests/test-complex/test_complex.ml
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,13 @@ struct
assert_equal ~cmp:complex32_eq (Complex.mul l r) (mul_complexf_val l r);

let zinf = { re = 0.; im = infinity } in
assert_equal 0. (add_complexd_val zinf zinf).re;
let res = add_complexd_val zinf zinf in
assert_equal 0. res.re;
assert_equal 0. (add_complexf_val zinf zinf).re;
let ozinf = Obj.repr zinf in
let ores = Obj.repr res in
assert_equal (Obj.tag ozinf) (Obj.tag ores);
assert_equal (Obj.size ozinf) (Obj.size ores);

(* test long double complex *)
let re x = LDouble.(to_float (ComplexL.re x)) in
Expand Down

0 comments on commit 38cc3c1

Please sign in to comment.