1
0
mirror of https://github.com/janet-lang/janet synced 2025-12-18 22:48:06 +00:00

refactor(c-api): Dogfooding usage of size types and limits

This commit is contained in:
GrayJack
2024-04-16 16:22:28 -03:00
parent 3f54b282dd
commit b483c9e2e4
14 changed files with 65 additions and 62 deletions

View File

@@ -70,7 +70,7 @@ void num_array_put(void *p, Janet key, Janet value) {
if (!janet_checktype(value, JANET_NUMBER))
janet_panic("expected number value");
index = (size_t)janet_unwrap_integer(key);
index = janet_unwrap_size(key);
if (index < array->size) {
array->data[index] = janet_unwrap_number(value);
}
@@ -96,7 +96,7 @@ int num_array_get(void *p, Janet key, Janet *out) {
return janet_getmethod(janet_unwrap_keyword(key), methods, out);
if (!janet_checkint(key))
janet_panic("expected integer key");
index = (size_t)janet_unwrap_integer(key);
index = janet_unwrap_size(key);
if (index >= array->size) {
return 0;
} else {