Move mrb_assert() position.

parent 5d0b9459
...@@ -121,6 +121,9 @@ mrb_str_buf_new(mrb_state *mrb, size_t capa) ...@@ -121,6 +121,9 @@ mrb_str_buf_new(mrb_state *mrb, size_t capa)
static void static void
resize_capa(mrb_state *mrb, struct RString *s, size_t capacity) resize_capa(mrb_state *mrb, struct RString *s, size_t capacity)
{ {
#if SIZE_MAX > MRB_INT_MAX
mrb_assert(capacity < MRB_INT_MAX);
#endif
if (RSTR_EMBED_P(s)) { if (RSTR_EMBED_P(s)) {
if (RSTRING_EMBED_LEN_MAX < capacity) { if (RSTRING_EMBED_LEN_MAX < capacity) {
char *const tmp = (char *)mrb_malloc(mrb, capacity+1); char *const tmp = (char *)mrb_malloc(mrb, capacity+1);
...@@ -133,9 +136,6 @@ resize_capa(mrb_state *mrb, struct RString *s, size_t capacity) ...@@ -133,9 +136,6 @@ resize_capa(mrb_state *mrb, struct RString *s, size_t capacity)
} }
} }
else { else {
#if SIZE_MAX > MRB_INT_MAX
mrb_assert(capacity <= MRB_INT_MAX);
#endif
s->as.heap.ptr = (char *)mrb_realloc(mrb, RSTR_PTR(s), capacity+1); s->as.heap.ptr = (char *)mrb_realloc(mrb, RSTR_PTR(s), capacity+1);
s->as.heap.aux.capa = capacity; s->as.heap.aux.capa = capacity;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment