Skip to content
Permalink
Browse files
Use mrb_int instead of size_t for array capacity and length.
  • Loading branch information
matz committed Jun 16, 2017
1 parent 0411cea commit aa8121cf3a25de845d9b90a518f840eddf265afe
Showing 1 changed file with 7 additions and 7 deletions.
@@ -122,7 +122,7 @@ ary_modify(mrb_state *mrb, struct RArray *a)
}
else {
mrb_value *ptr, *p;
size_t len;
mrb_int len;

p = a->ptr;
len = a->len * sizeof(mrb_value);
@@ -165,9 +165,9 @@ ary_make_shared(mrb_state *mrb, struct RArray *a)
}

static void
ary_expand_capa(mrb_state *mrb, struct RArray *a, size_t len)
ary_expand_capa(mrb_state *mrb, struct RArray *a, mrb_int len)
{
size_t capa = a->aux.capa;
mrb_int capa = a->aux.capa;

if (len > ARY_MAX_SIZE) {
size_error:
@@ -189,10 +189,10 @@ ary_expand_capa(mrb_state *mrb, struct RArray *a, size_t len)
goto size_error;
}

if (capa > (size_t)a->aux.capa) {
if (capa > a->aux.capa) {
mrb_value *expanded_ptr = (mrb_value *)mrb_realloc(mrb, a->ptr, sizeof(mrb_value)*capa);

a->aux.capa = (mrb_int)capa;
a->aux.capa = capa;
a->ptr = expanded_ptr;
}
}
@@ -596,7 +596,7 @@ mrb_ary_splice(mrb_state *mrb, mrb_value ary, mrb_int head, mrb_int len, mrb_val
struct RArray *a = mrb_ary_ptr(ary);
const mrb_value *argv;
mrb_int argc;
size_t tail;
mrb_int tail;

ary_modify(mrb, a);

@@ -611,7 +611,7 @@ mrb_ary_splice(mrb_state *mrb, mrb_value ary, mrb_int head, mrb_int len, mrb_val
}
}
tail = head + len;
if (a->len < len || (size_t)a->len < tail) {
if (a->len < len || a->len < tail) {
len = a->len - head;
}

0 comments on commit aa8121c

Please sign in to comment.