diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2019-08-19 07:24:06 +0900 |
|---|---|---|
| committer | GitHub <[email protected]> | 2019-08-19 07:24:06 +0900 |
| commit | 1b9801a04b3182e702a21e1de1c83269e8e3224a (patch) | |
| tree | 4de87b0e8c6d81d9531f02fde9cacd44ccb348ae /src | |
| parent | feecb3321a8d528b29524f9ff7c991b5432f7600 (diff) | |
| parent | d2d201cc821ee46029d98c1fcd4706bc86c78ac6 (diff) | |
| download | mruby-1b9801a04b3182e702a21e1de1c83269e8e3224a.tar.gz mruby-1b9801a04b3182e702a21e1de1c83269e8e3224a.zip | |
Merge pull request #4641 from shuujii/rename-mrb_shared_string-len-to-mrb_shared_string-capa
Rename `mrb_shared_string::len` to `mrb_shared_string::capa`
Diffstat (limited to 'src')
| -rw-r--r-- | src/string.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/string.c b/src/string.c index 10e20c3b1..1edbff802 100644 --- a/src/string.c +++ b/src/string.c @@ -24,7 +24,7 @@ typedef struct mrb_shared_string { int refcnt; - mrb_int len; + mrb_int capa; char *ptr; } mrb_shared_string; @@ -79,7 +79,7 @@ str_init_shared(mrb_state *mrb, const struct RString *orig, struct RString *s, m shared = (mrb_shared_string *)mrb_malloc(mrb, sizeof(mrb_shared_string)); shared->refcnt = 1; shared->ptr = orig->as.heap.ptr; - shared->len = orig->as.heap.len; + shared->capa = orig->as.heap.aux.capa; } s->as.heap.ptr = orig->as.heap.ptr; s->as.heap.len = orig->as.heap.len; @@ -534,6 +534,7 @@ str_make_shared(mrb_state *mrb, struct RString *orig, struct RString *s) else { if (orig->as.heap.aux.capa > orig->as.heap.len) { orig->as.heap.ptr = (char *)mrb_realloc(mrb, orig->as.heap.ptr, len+1); + orig->as.heap.aux.capa = len; } str_init_shared(mrb, orig, s, NULL); str_init_shared(mrb, orig, orig, s->as.heap.aux.shared); @@ -779,7 +780,7 @@ mrb_str_modify_keep_ascii(mrb_state *mrb, struct RString *s) mrb_shared_string *shared = s->as.heap.aux.shared; if (shared->refcnt == 1 && s->as.heap.ptr == shared->ptr) { - s->as.heap.aux.capa = shared->len; + s->as.heap.aux.capa = shared->capa; s->as.heap.ptr[s->as.heap.len] = '\0'; mrb_free(mrb, shared); } |
