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
8cef93d2
Commit
8cef93d2
authored
Jul 08, 2012
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #355 from monaka/pr-use-mrb_calloc
Use mrb_calloc if you want zero cleard buffers.
parents
78614b23
611cf71a
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
8 additions
and
18 deletions
+8
-18
src/array.c
src/array.c
+1
-2
src/dump.c
src/dump.c
+2
-5
src/gc.c
src/gc.c
+1
-3
src/parse.y
src/parse.y
+1
-2
src/state.c
src/state.c
+1
-2
src/vm.c
src/vm.c
+2
-4
No files found.
src/array.c
View file @
8cef93d2
...
...
@@ -46,8 +46,7 @@ ary_new_capa(mrb_state *mrb, int capa)
}
a
=
(
struct
RArray
*
)
mrb_obj_alloc
(
mrb
,
MRB_TT_ARRAY
,
mrb
->
array_class
);
a
->
ptr
=
mrb_malloc
(
mrb
,
blen
);
memset
(
a
->
ptr
,
0
,
blen
);
a
->
ptr
=
mrb_calloc
(
mrb
,
blen
,
1
);
a
->
aux
.
capa
=
capa
;
a
->
len
=
0
;
...
...
src/dump.c
View file @
8cef93d2
...
...
@@ -460,11 +460,10 @@ calc_crc_section(mrb_state *mrb, mrb_irep *irep, uint16_t *crc, int section)
default:
return
MRB_DUMP_GENERAL_FAILURE
;
}
if
((
buf
=
mrb_
malloc
(
mrb
,
buf_size
))
==
0
)
if
((
buf
=
mrb_
calloc
(
mrb
,
1
,
buf_size
))
==
0
)
return
MRB_DUMP_GENERAL_FAILURE
;
buf_top
=
buf
;
memset
(
buf
,
0
,
buf_size
);
switch
(
section
)
{
case
DUMP_IREP_HEADER
:
buf
+=
write_irep_header
(
mrb
,
irep
,
buf
,
type
);
break
;
...
...
@@ -598,11 +597,9 @@ dump_irep_record(mrb_state *mrb, int irep_no, FILE* fp, uint32_t *rlen)
if
(
irep_record_size
==
0
)
return
MRB_DUMP_GENERAL_FAILURE
;
if
((
buf
=
mrb_
malloc
(
mrb
,
irep_record_size
))
==
0
)
if
((
buf
=
mrb_
calloc
(
mrb
,
1
,
irep_record_size
))
==
0
)
return
MRB_DUMP_GENERAL_FAILURE
;
memset
(
buf
,
0
,
irep_record_size
);
if
((
rc
=
write_irep_record
(
mrb
,
irep_no
,
buf
,
rlen
,
DUMP_TYPE_HEX
))
!=
MRB_DUMP_OK
)
{
rc
=
MRB_DUMP_GENERAL_FAILURE
;
goto
error_exit
;
...
...
src/gc.c
View file @
8cef93d2
...
...
@@ -246,12 +246,10 @@ unlink_free_heap_page(mrb_state *mrb, struct heap_page *page)
static
void
add_heap
(
mrb_state
*
mrb
)
{
struct
heap_page
*
page
=
mrb_
malloc
(
mrb
,
sizeof
(
struct
heap_page
));
struct
heap_page
*
page
=
mrb_
calloc
(
mrb
,
1
,
sizeof
(
struct
heap_page
));
RVALUE
*
p
,
*
e
;
struct
RBasic
*
prev
=
NULL
;
memset
(
page
,
0
,
sizeof
(
struct
heap_page
));
for
(
p
=
page
->
objects
,
e
=
p
+
HEAP_PAGE_SIZE
;
p
<
e
;
p
++
)
{
p
->
as
.
free
.
tt
=
MRB_TT_FREE
;
p
->
as
.
free
.
next
=
prev
;
...
...
src/parse.y
View file @
8cef93d2
...
...
@@ -4792,8 +4792,7 @@ mrbc_context_new(mrb_state *mrb)
{
mrbc_context *c;
c = mrb_malloc(mrb, sizeof(mrbc_context));
memset(c, 0, sizeof(mrbc_context));
c = mrb_calloc(mrb, 1, sizeof(mrbc_context));
return c;
}
...
...
src/state.c
View file @
8cef93d2
...
...
@@ -76,8 +76,7 @@ mrb_add_irep(mrb_state *mrb, int idx)
int
max
=
256
;
if
(
idx
>
max
)
max
=
idx
+
1
;
mrb
->
irep
=
mrb_malloc
(
mrb
,
sizeof
(
mrb_irep
*
)
*
max
);
memset
(
mrb
->
irep
,
0
,
sizeof
(
mrb_irep
*
)
*
max
);
mrb
->
irep
=
mrb_calloc
(
mrb
,
max
,
sizeof
(
mrb_irep
*
));
mrb
->
irep_capa
=
max
;
}
else
if
(
mrb
->
irep_capa
<=
idx
)
{
...
...
src/vm.c
View file @
8cef93d2
...
...
@@ -28,16 +28,14 @@ static void
stack_init
(
mrb_state
*
mrb
)
{
/* assert(mrb->stack == NULL); */
mrb
->
stbase
=
mrb_malloc
(
mrb
,
sizeof
(
mrb_value
)
*
STACK_INIT_SIZE
);
memset
(
mrb
->
stbase
,
0
,
sizeof
(
mrb_value
)
*
STACK_INIT_SIZE
);
mrb
->
stbase
=
mrb_calloc
(
mrb
,
STACK_INIT_SIZE
,
sizeof
(
mrb_value
));
mrb
->
stend
=
mrb
->
stbase
+
STACK_INIT_SIZE
;
mrb
->
stack
=
mrb
->
stbase
;
/* assert(mrb->ci == NULL); */
mrb
->
cibase
=
mrb_
malloc
(
mrb
,
sizeof
(
mrb_callinfo
)
*
CALLINFO_INIT_SIZE
);
mrb
->
cibase
=
mrb_
calloc
(
mrb
,
CALLINFO_INIT_SIZE
,
sizeof
(
mrb_callinfo
)
);
mrb
->
ciend
=
mrb
->
cibase
+
CALLINFO_INIT_SIZE
;
mrb
->
ci
=
mrb
->
cibase
;
memset
(
mrb
->
ci
,
0
,
sizeof
(
mrb_callinfo
));
mrb
->
ci
->
target_class
=
mrb
->
object_class
;
}
...
...
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