Closed erikvanzijst closed 4 years ago
Hi @erikvanzijst I've changed the method signature to accept a Pointer
rather than an int
. Now if you look at the tests in PaddingTest
, you can see how it works:
@Test
public void pad() {
IntByReference ref = new IntByReference(0);
char[] b = new char[4];
lazySodium.sodiumPad(ref, b, 4, 4, 10);
TestCase.assertEquals(8, ref.getValue());
}
Cool, thanks for the quick clarification and fix!
The
Sodium.sodium_pad
native method declares thepaddedBuffLen
argument as a pass-by-value int.The documentation in
Padding.Native
states thatpaddedBuffLen
is the new length of the buffer:However, it seems that the C function takes a
size_t
pointer which it only writes a new value to.I might be overlooking something, but isn't the pointer used to communicate the padded length back to the caller? Something that doesn't work with Java's call-by-value primitives?