diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-06-11 12:15:33 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-06-11 12:15:33 +0900 |
| commit | 63be55c77c98cd77b5e2468719b23f5cedca3df8 (patch) | |
| tree | be1e0817bc426efc291d78ce4f3288f4d4fcd43f /src | |
| parent | fe95f4401390a88b26e9c8cf6d20c217e577a17f (diff) | |
| parent | 9c259c501a619d7e1ca34f5092fbbe4e6c9d40b9 (diff) | |
| download | mruby-63be55c77c98cd77b5e2468719b23f5cedca3df8.tar.gz mruby-63be55c77c98cd77b5e2468719b23f5cedca3df8.zip | |
Merge pull request #2386 from suzukaze/add-nofree-macro
Add NOFREE macros
Diffstat (limited to 'src')
| -rw-r--r-- | src/string.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/string.c b/src/string.c index 734bf739a..6d2799270 100644 --- a/src/string.c +++ b/src/string.c @@ -106,7 +106,7 @@ mrb_str_modify(mrb_state *mrb, struct RString *s) RSTR_UNSET_SHARED_FLAG(s); return; } - if (s->flags & MRB_STR_NOFREE) { + if (RSTR_NOFREE_P(s)) { char *p = s->as.heap.ptr; s->as.heap.ptr = (char *)mrb_malloc(mrb, (size_t)s->as.heap.len+1); @@ -115,7 +115,7 @@ mrb_str_modify(mrb_state *mrb, struct RString *s) } RSTR_PTR(s)[s->as.heap.len] = '\0'; s->as.heap.aux.capa = s->as.heap.len; - s->flags &= ~MRB_STR_NOFREE; + RSTR_UNSET_NOFREE_FLAG(s); return; } } @@ -302,7 +302,7 @@ mrb_gc_free_str(mrb_state *mrb, struct RString *str) /* no code */; else if (RSTR_SHARED_P(str)) str_decref(mrb, str->as.heap.aux.shared); - else if ((str->flags & MRB_STR_NOFREE) == 0) + else if (RSTR_NOFREE_P(str) == 0) mrb_free(mrb, str->as.heap.ptr); } @@ -340,10 +340,10 @@ str_make_shared(mrb_state *mrb, struct RString *s) shared->nofree = FALSE; shared->ptr = s->as.heap.ptr; } - else if (s->flags & MRB_STR_NOFREE) { + else if (RSTR_NOFREE_P(s)) { shared->nofree = TRUE; shared->ptr = s->as.heap.ptr; - s->flags &= ~MRB_STR_NOFREE; + RSTR_UNSET_NOFREE_FLAG(s); } else { shared->nofree = FALSE; @@ -1373,7 +1373,7 @@ str_replace(mrb_state *mrb, struct RString *s1, struct RString *s2) if (RSTR_SHARED_P(s1)) { str_decref(mrb, s1->as.heap.aux.shared); } - else if (!RSTR_EMBED_P(s1) && !(s1->flags & MRB_STR_NOFREE)) { + else if (!RSTR_EMBED_P(s1) && !RSTR_NOFREE_P(s1)) { mrb_free(mrb, s1->as.heap.ptr); } RSTR_UNSET_EMBED_FLAG(s1); |
