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
d62ce565
Commit
d62ce565
authored
Jun 04, 2014
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use pre-allocated RuntimeError for out-of-memory
parent
b01bb33b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
4 deletions
+8
-4
include/mruby.h
include/mruby.h
+1
-0
src/error.c
src/error.c
+6
-3
src/gc.c
src/gc.c
+1
-1
No files found.
include/mruby.h
View file @
d62ce565
...
@@ -167,6 +167,7 @@ typedef struct mrb_state {
...
@@ -167,6 +167,7 @@ typedef struct mrb_state {
struct
RClass
*
eException_class
;
struct
RClass
*
eException_class
;
struct
RClass
*
eStandardError_class
;
struct
RClass
*
eStandardError_class
;
struct
RObject
*
nomem_err
;
/* pre-allocated NoMemoryError */
void
*
ud
;
/* auxiliary data */
void
*
ud
;
/* auxiliary data */
}
mrb_state
;
}
mrb_state
;
...
...
src/error.c
View file @
d62ce565
...
@@ -227,7 +227,9 @@ mrb_noreturn void
...
@@ -227,7 +227,9 @@ mrb_noreturn void
mrb_exc_raise
(
mrb_state
*
mrb
,
mrb_value
exc
)
mrb_exc_raise
(
mrb_state
*
mrb
,
mrb_value
exc
)
{
{
mrb
->
exc
=
mrb_obj_ptr
(
exc
);
mrb
->
exc
=
mrb_obj_ptr
(
exc
);
if
(
!
mrb
->
out_of_memory
)
{
exc_debug_info
(
mrb
,
mrb
->
exc
);
exc_debug_info
(
mrb
,
mrb
->
exc
);
}
if
(
!
mrb
->
jmp
)
{
if
(
!
mrb
->
jmp
)
{
mrb_p
(
mrb
,
exc
);
mrb_p
(
mrb
,
exc
);
abort
();
abort
();
...
@@ -459,7 +461,7 @@ mrb_no_method_error(mrb_state *mrb, mrb_sym id, mrb_int argc, const mrb_value *a
...
@@ -459,7 +461,7 @@ mrb_no_method_error(mrb_state *mrb, mrb_sym id, mrb_int argc, const mrb_value *a
void
void
mrb_init_exception
(
mrb_state
*
mrb
)
mrb_init_exception
(
mrb_state
*
mrb
)
{
{
struct
RClass
*
exception
,
*
script_error
;
struct
RClass
*
exception
,
*
runtime_error
,
*
script_error
;
mrb
->
eException_class
=
exception
=
mrb_define_class
(
mrb
,
"Exception"
,
mrb
->
object_class
);
/* 15.2.22 */
mrb
->
eException_class
=
exception
=
mrb_define_class
(
mrb
,
"Exception"
,
mrb
->
object_class
);
/* 15.2.22 */
mrb_define_class_method
(
mrb
,
exception
,
"exception"
,
mrb_instance_new
,
MRB_ARGS_ANY
());
mrb_define_class_method
(
mrb
,
exception
,
"exception"
,
mrb_instance_new
,
MRB_ARGS_ANY
());
...
@@ -472,7 +474,8 @@ mrb_init_exception(mrb_state *mrb)
...
@@ -472,7 +474,8 @@ mrb_init_exception(mrb_state *mrb)
mrb_define_method
(
mrb
,
exception
,
"backtrace"
,
mrb_exc_backtrace
,
MRB_ARGS_NONE
());
mrb_define_method
(
mrb
,
exception
,
"backtrace"
,
mrb_exc_backtrace
,
MRB_ARGS_NONE
());
mrb
->
eStandardError_class
=
mrb_define_class
(
mrb
,
"StandardError"
,
mrb
->
eException_class
);
/* 15.2.23 */
mrb
->
eStandardError_class
=
mrb_define_class
(
mrb
,
"StandardError"
,
mrb
->
eException_class
);
/* 15.2.23 */
mrb_define_class
(
mrb
,
"RuntimeError"
,
mrb
->
eStandardError_class
);
/* 15.2.28 */
runtime_error
=
mrb_define_class
(
mrb
,
"RuntimeError"
,
mrb
->
eStandardError_class
);
/* 15.2.28 */
mrb
->
nomem_err
=
mrb_obj_ptr
(
mrb_exc_new_str
(
mrb
,
runtime_error
,
mrb_str_new_lit
(
mrb
,
"Out of memory"
)));
script_error
=
mrb_define_class
(
mrb
,
"ScriptError"
,
mrb
->
eException_class
);
/* 15.2.37 */
script_error
=
mrb_define_class
(
mrb
,
"ScriptError"
,
mrb
->
eException_class
);
/* 15.2.37 */
mrb_define_class
(
mrb
,
"SyntaxError"
,
script_error
);
/* 15.2.38 */
mrb_define_class
(
mrb
,
"SyntaxError"
,
script_error
);
/* 15.2.38 */
}
}
src/gc.c
View file @
d62ce565
...
@@ -189,7 +189,7 @@ mrb_realloc(mrb_state *mrb, void *p, size_t len)
...
@@ -189,7 +189,7 @@ mrb_realloc(mrb_state *mrb, void *p, size_t len)
}
}
else
{
else
{
mrb
->
out_of_memory
=
TRUE
;
mrb
->
out_of_memory
=
TRUE
;
mrb_
raise
(
mrb
,
E_RUNTIME_ERROR
,
"Out of memory"
);
mrb_
exc_raise
(
mrb
,
mrb_obj_value
(
mrb
->
nomem_err
)
);
}
}
}
}
else
{
else
{
...
...
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