From a88f8d54e1db241a3a25c4248a3472d7be3e961b Mon Sep 17 00:00:00 2001 From: iWas-Coder Date: Sat, 11 May 2024 03:48:40 +0200 Subject: [PATCH] fix: `element_size` must be `usz` type (`size_t`) --- include/sk_rngbuf.h | 2 +- src/sk_rngbuf.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/sk_rngbuf.h b/include/sk_rngbuf.h index d41627c..da0ff09 100644 --- a/include/sk_rngbuf.h +++ b/include/sk_rngbuf.h @@ -35,7 +35,7 @@ typedef struct { void *data; } sk_rngbuf; -sk_rngbuf sk_rngbuf_create(u32 capacity, u32 element_size, u8 overwrite); +sk_rngbuf sk_rngbuf_create(u32 capacity, usz element_size, u8 overwrite); void sk_rngbuf_destroy(sk_rngbuf *rb); diff --git a/src/sk_rngbuf.c b/src/sk_rngbuf.c index cf2b7f2..a129a30 100644 --- a/src/sk_rngbuf.c +++ b/src/sk_rngbuf.c @@ -24,7 +24,7 @@ #include #include -sk_rngbuf sk_rngbuf_create(u32 capacity, u32 element_size, u8 overwrite) { +sk_rngbuf sk_rngbuf_create(u32 capacity, usz element_size, u8 overwrite) { return (sk_rngbuf) { .capacity = capacity, .element_size = element_size, @@ -32,7 +32,7 @@ sk_rngbuf sk_rngbuf_create(u32 capacity, u32 element_size, u8 overwrite) { .curr_len = 0, .head = 0, .tail = -1, - .data = malloc(capacity * element_size) + .data = malloc((usz) capacity * element_size) }; }