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
8a6e6005
Commit
8a6e6005
authored
Nov 04, 2014
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avoid using rewind(3) to load mrb files
parent
0e2ab221
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
7 deletions
+8
-7
src/load.c
src/load.c
+8
-7
No files found.
src/load.c
View file @
8a6e6005
...
...
@@ -653,7 +653,8 @@ mrb_read_irep_file(mrb_state *mrb, FILE* fp)
{
mrb_irep
*
irep
=
NULL
;
uint8_t
*
buf
;
size_t
buf_size
=
sizeof
(
struct
rite_binary_header
);
const
size_t
header_size
=
sizeof
(
struct
rite_binary_header
);
size_t
buf_size
=
0
;
uint8_t
flags
;
int
result
;
...
...
@@ -662,25 +663,25 @@ mrb_read_irep_file(mrb_state *mrb, FILE* fp)
}
/* You don't need use SIZE_ERROR as buf_size is enough small. */
buf
=
(
uint8_t
*
)
mrb_malloc
(
mrb
,
buf
_size
);
if
(
fread
(
buf
,
buf
_size
,
1
,
fp
)
==
0
)
{
buf
=
(
uint8_t
*
)
mrb_malloc
(
mrb
,
header
_size
);
if
(
fread
(
buf
,
header
_size
,
1
,
fp
)
==
0
)
{
mrb_free
(
mrb
,
buf
);
return
NULL
;
}
result
=
read_binary_header
(
buf
,
&
buf_size
,
NULL
,
&
flags
);
mrb_free
(
mrb
,
buf
);
if
(
result
!=
MRB_DUMP_OK
)
{
mrb_free
(
mrb
,
buf
);
return
NULL
;
}
buf
=
(
uint8_t
*
)
mrb_malloc
(
mrb
,
buf_size
);
rewind
(
fp
);
if
(
fread
(
buf
,
buf_size
,
1
,
fp
)
==
0
)
{
buf
=
(
uint8_t
*
)
mrb_realloc
(
mrb
,
buf
,
buf_size
);
if
(
fread
(
buf
+
header_size
,
buf_size
-
header_size
,
1
,
fp
)
==
0
)
{
mrb_free
(
mrb
,
buf
);
return
NULL
;
}
irep
=
read_irep
(
mrb
,
buf
,
FLAG_SRC_MALLOC
);
mrb_free
(
mrb
,
buf
);
return
irep
;
}
...
...
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