Skip to content

Commit 3796194

Browse files
elichaiTheBlueMatt
authored andcommitted
Add a size_t type to types
1 parent f033422 commit 3796194

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

secp256k1-sys/src/lib.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ extern "C" {
152152

153153
// Contexts
154154
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_1_1_context_preallocated_size")]
155-
pub fn secp256k1_context_preallocated_size(flags: c_uint) -> usize;
155+
pub fn secp256k1_context_preallocated_size(flags: c_uint) -> size_t;
156156

157157
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_1_1_context_preallocated_create")]
158158
pub fn secp256k1_context_preallocated_create(prealloc: *mut c_void, flags: c_uint) -> *mut Context;
@@ -161,7 +161,7 @@ extern "C" {
161161
pub fn secp256k1_context_preallocated_destroy(cx: *mut Context);
162162

163163
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_1_1_context_preallocated_clone_size")]
164-
pub fn secp256k1_context_preallocated_clone_size(cx: *const Context) -> usize;
164+
pub fn secp256k1_context_preallocated_clone_size(cx: *const Context) -> size_t;
165165

166166
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_1_1_context_preallocated_clone")]
167167
pub fn secp256k1_context_preallocated_clone(cx: *const Context, prealloc: *mut c_void) -> *mut Context;
@@ -174,19 +174,19 @@ extern "C" {
174174
// Pubkeys
175175
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_1_1_ec_pubkey_parse")]
176176
pub fn secp256k1_ec_pubkey_parse(cx: *const Context, pk: *mut PublicKey,
177-
input: *const c_uchar, in_len: usize)
177+
input: *const c_uchar, in_len: size_t)
178178
-> c_int;
179179

180180
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_1_1_ec_pubkey_serialize")]
181181
pub fn secp256k1_ec_pubkey_serialize(cx: *const Context, output: *mut c_uchar,
182-
out_len: *mut usize, pk: *const PublicKey,
182+
out_len: *mut size_t, pk: *const PublicKey,
183183
compressed: c_uint)
184184
-> c_int;
185185

186186
// Signatures
187187
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_1_1_ecdsa_signature_parse_der")]
188188
pub fn secp256k1_ecdsa_signature_parse_der(cx: *const Context, sig: *mut Signature,
189-
input: *const c_uchar, in_len: usize)
189+
input: *const c_uchar, in_len: size_t)
190190
-> c_int;
191191

192192
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_1_1_ecdsa_signature_parse_compact")]
@@ -196,12 +196,12 @@ extern "C" {
196196

197197
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_1_1_ecdsa_signature_parse_der_lax")]
198198
pub fn ecdsa_signature_parse_der_lax(cx: *const Context, sig: *mut Signature,
199-
input: *const c_uchar, in_len: usize)
199+
input: *const c_uchar, in_len: size_t)
200200
-> c_int;
201201

202202
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_1_1_ecdsa_signature_serialize_der")]
203203
pub fn secp256k1_ecdsa_signature_serialize_der(cx: *const Context, output: *mut c_uchar,
204-
out_len: *mut usize, sig: *const Signature)
204+
out_len: *mut size_t, sig: *const Signature)
205205
-> c_int;
206206

207207
#[cfg_attr(not(feature = "external-symbols"), link_name = "rustsecp256k1_v0_1_1_ecdsa_signature_serialize_compact")]
@@ -462,12 +462,12 @@ mod fuzz_dummy {
462462
}
463463

464464
/// Return dummy size of context struct.
465-
pub unsafe fn secp256k1_context_preallocated_size(_flags: c_uint) -> usize {
465+
pub unsafe fn secp256k1_context_preallocated_size(_flags: c_uint) -> size_t {
466466
mem::size_of::<Context>()
467467
}
468468

469469
/// Return dummy size of context struct.
470-
pub unsafe fn secp256k1_context_preallocated_clone_size(_cx: *mut Context) -> usize {
470+
pub unsafe fn secp256k1_context_preallocated_clone_size(_cx: *mut Context) -> size_t {
471471
mem::size_of::<Context>()
472472
}
473473

@@ -494,7 +494,7 @@ mod fuzz_dummy {
494494
// Pubkeys
495495
/// Parse 33/65 byte pubkey into PublicKey, losing compressed information
496496
pub unsafe fn secp256k1_ec_pubkey_parse(cx: *const Context, pk: *mut PublicKey,
497-
input: *const c_uchar, in_len: usize)
497+
input: *const c_uchar, in_len: size_t)
498498
-> c_int {
499499
assert!(!cx.is_null() && (*cx).0 as u32 & !(SECP256K1_START_NONE | SECP256K1_START_VERIFY | SECP256K1_START_SIGN) == 0);
500500
match in_len {
@@ -521,7 +521,7 @@ mod fuzz_dummy {
521521

522522
/// Serialize PublicKey back to 33/65 byte pubkey
523523
pub unsafe fn secp256k1_ec_pubkey_serialize(cx: *const Context, output: *mut c_uchar,
524-
out_len: *mut usize, pk: *const PublicKey,
524+
out_len: *mut size_t, pk: *const PublicKey,
525525
compressed: c_uint)
526526
-> c_int {
527527
assert!(!cx.is_null() && (*cx).0 as u32 & !(SECP256K1_START_NONE | SECP256K1_START_VERIFY | SECP256K1_START_SIGN) == 0);
@@ -546,7 +546,7 @@ mod fuzz_dummy {
546546

547547
// Signatures
548548
pub unsafe fn secp256k1_ecdsa_signature_parse_der(_cx: *const Context, _sig: *mut Signature,
549-
_input: *const c_uchar, _in_len: usize)
549+
_input: *const c_uchar, _in_len: size_t)
550550
-> c_int {
551551
unimplemented!();
552552
}
@@ -562,14 +562,14 @@ mod fuzz_dummy {
562562
}
563563

564564
pub unsafe fn ecdsa_signature_parse_der_lax(_cx: *const Context, _sig: *mut Signature,
565-
_input: *const c_uchar, _in_len: usize)
565+
_input: *const c_uchar, _in_len: size_t)
566566
-> c_int {
567567
unimplemented!();
568568
}
569569

570570
/// Copies up to 72 bytes into output from sig
571571
pub unsafe fn secp256k1_ecdsa_signature_serialize_der(cx: *const Context, output: *mut c_uchar,
572-
out_len: *mut usize, sig: *const Signature)
572+
out_len: *mut size_t, sig: *const Signature)
573573
-> c_int {
574574
assert!(!cx.is_null() && (*cx).0 as u32 & !(SECP256K1_START_NONE | SECP256K1_START_VERIFY | SECP256K1_START_SIGN) == 0);
575575

secp256k1-sys/src/types.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use core::fmt;
44
pub type c_int = i32;
55
pub type c_uchar = u8;
66
pub type c_uint = u32;
7+
pub type size_t = usize;
78

89
/// This might not match C's `c_char` exactly.
910
/// The way we use it makes it fine either way but this type shouldn't be used outside of the library.

0 commit comments

Comments
 (0)