Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
28b9619b
Commit
28b9619b
authored
Jun 03, 2012
by
Yukihiro Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
should decref shared string body on gc_free
parent
60e8d80f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
6 deletions
+15
-6
include/mruby/string.h
include/mruby/string.h
+1
-0
src/gc.c
src/gc.c
+3
-1
src/string.c
src/string.c
+11
-5
No files found.
include/mruby/string.h
View file @
28b9619b
...
...
@@ -49,6 +49,7 @@ struct RString {
#define RSTRING_END(s) (RSTRING(s)->buf + RSTRING(s)->len)
#define MRB_STR_SHARED 256
void
mrb_str_decref
(
mrb_state
*
,
struct
mrb_shared_string
*
);
mrb_value
mrb_str_literal
(
mrb_state
*
,
mrb_value
);
void
mrb_str_concat
(
mrb_state
*
,
mrb_value
,
mrb_value
);
mrb_value
mrb_obj_to_str
(
mrb_state
*
,
mrb_value
);
...
...
src/gc.c
View file @
28b9619b
...
...
@@ -460,7 +460,9 @@ obj_free(mrb_state *mrb, struct RBasic *obj)
break
;
case
MRB_TT_STRING
:
if
(
!
(
obj
->
flags
&
MRB_STR_SHARED
))
if
(
obj
->
flags
&
MRB_STR_SHARED
)
mrb_str_decref
(
mrb
,
((
struct
RString
*
)
obj
)
->
aux
.
shared
);
else
mrb_free
(
mrb
,
((
struct
RString
*
)
obj
)
->
buf
);
break
;
...
...
src/string.c
View file @
28b9619b
...
...
@@ -43,6 +43,16 @@ static mrb_value mrb_str_subseq(mrb_state *mrb, mrb_value str, int beg, int len)
s->aux.capa = capacity;\
} while (0)
void
mrb_str_decref
(
mrb_state
*
mrb
,
struct
mrb_shared_string
*
shared
)
{
shared
->
refcnt
--
;
if
(
shared
->
refcnt
==
0
)
{
mrb_free
(
mrb
,
shared
->
buf
);
mrb_free
(
mrb
,
shared
);
}
}
static
void
str_modify
(
mrb_state
*
mrb
,
struct
RString
*
s
)
{
...
...
@@ -63,11 +73,7 @@ str_modify(mrb_state *mrb, struct RString *s)
s
->
aux
.
capa
=
len
;
s
->
flags
&=
~
MRB_STR_SHARED
;
shared
->
refcnt
--
;
if
(
shared
->
refcnt
==
0
)
{
mrb_free
(
mrb
,
shared
->
buf
);
mrb_free
(
mrb
,
shared
);
}
mrb_str_decref
(
mrb
,
shared
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment