summaryrefslogtreecommitdiffhomepage
path: root/src/string.c
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2017-01-06 14:51:21 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2017-01-06 14:51:21 +0900
commit9a76a0bd809e06089e6a09aa72e01ccf82806056 (patch)
tree42bcb5c8de2d8aea43823d2017a3c7839771d021 /src/string.c
parent5d0b9459ff6b92f4a5a6252c8d2c7000c4ef1135 (diff)
downloadmruby-9a76a0bd809e06089e6a09aa72e01ccf82806056.tar.gz
mruby-9a76a0bd809e06089e6a09aa72e01ccf82806056.zip
Move mrb_assert() position.
Diffstat (limited to 'src/string.c')
-rw-r--r--src/string.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/string.c b/src/string.c
index d011f60ca..5aaef5826 100644
--- a/src/string.c
+++ b/src/string.c
@@ -121,6 +121,9 @@ mrb_str_buf_new(mrb_state *mrb, size_t capa)
static void
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 (RSTRING_EMBED_LEN_MAX < capacity) {
char *const tmp = (char *)mrb_malloc(mrb, capacity+1);
@@ -133,9 +136,6 @@ resize_capa(mrb_state *mrb, struct RString *s, size_t capacity)
}
}
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.aux.capa = capacity;
}