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
306b1d3c
Commit
306b1d3c
authored
Mar 26, 2014
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1948 from monaka/pr-remove-unused-null-check
Remove redundant NULL checks.
parents
79ba1ed1
dcff9012
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
4 additions
and
31 deletions
+4
-31
src/load.c
src/load.c
+0
-22
src/proc.c
src/proc.c
+0
-3
src/state.c
src/state.c
+0
-1
src/variable.c
src/variable.c
+4
-5
No files found.
src/load.c
View file @
306b1d3c
...
@@ -72,9 +72,6 @@ read_irep_record_1(mrb_state *mrb, const uint8_t *bin, size_t *len, mrb_bool all
...
@@ -72,9 +72,6 @@ read_irep_record_1(mrb_state *mrb, const uint8_t *bin, size_t *len, mrb_bool all
return
NULL
;
return
NULL
;
}
}
irep
->
iseq
=
(
mrb_code
*
)
mrb_malloc
(
mrb
,
sizeof
(
mrb_code
)
*
irep
->
ilen
);
irep
->
iseq
=
(
mrb_code
*
)
mrb_malloc
(
mrb
,
sizeof
(
mrb_code
)
*
irep
->
ilen
);
if
(
irep
->
iseq
==
NULL
)
{
return
NULL
;
}
for
(
i
=
0
;
i
<
irep
->
ilen
;
i
++
)
{
for
(
i
=
0
;
i
<
irep
->
ilen
;
i
++
)
{
irep
->
iseq
[
i
]
=
(
size_t
)
bin_to_uint32
(
src
);
/* iseq */
irep
->
iseq
[
i
]
=
(
size_t
)
bin_to_uint32
(
src
);
/* iseq */
src
+=
sizeof
(
uint32_t
);
src
+=
sizeof
(
uint32_t
);
...
@@ -89,9 +86,6 @@ read_irep_record_1(mrb_state *mrb, const uint8_t *bin, size_t *len, mrb_bool all
...
@@ -89,9 +86,6 @@ read_irep_record_1(mrb_state *mrb, const uint8_t *bin, size_t *len, mrb_bool all
return
NULL
;
return
NULL
;
}
}
irep
->
pool
=
(
mrb_value
*
)
mrb_malloc
(
mrb
,
sizeof
(
mrb_value
)
*
plen
);
irep
->
pool
=
(
mrb_value
*
)
mrb_malloc
(
mrb
,
sizeof
(
mrb_value
)
*
plen
);
if
(
irep
->
pool
==
NULL
)
{
return
NULL
;
}
for
(
i
=
0
;
i
<
plen
;
i
++
)
{
for
(
i
=
0
;
i
<
plen
;
i
++
)
{
mrb_value
s
;
mrb_value
s
;
...
@@ -137,9 +131,6 @@ read_irep_record_1(mrb_state *mrb, const uint8_t *bin, size_t *len, mrb_bool all
...
@@ -137,9 +131,6 @@ read_irep_record_1(mrb_state *mrb, const uint8_t *bin, size_t *len, mrb_bool all
return
NULL
;
return
NULL
;
}
}
irep
->
syms
=
(
mrb_sym
*
)
mrb_malloc
(
mrb
,
sizeof
(
mrb_sym
)
*
irep
->
slen
);
irep
->
syms
=
(
mrb_sym
*
)
mrb_malloc
(
mrb
,
sizeof
(
mrb_sym
)
*
irep
->
slen
);
if
(
irep
->
syms
==
NULL
)
{
return
NULL
;
}
for
(
i
=
0
;
i
<
irep
->
slen
;
i
++
)
{
for
(
i
=
0
;
i
<
irep
->
slen
;
i
++
)
{
snl
=
bin_to_uint16
(
src
);
/* symbol name length */
snl
=
bin_to_uint16
(
src
);
/* symbol name length */
...
@@ -217,9 +208,6 @@ read_lineno_record_1(mrb_state *mrb, const uint8_t *bin, mrb_irep *irep, size_t
...
@@ -217,9 +208,6 @@ read_lineno_record_1(mrb_state *mrb, const uint8_t *bin, mrb_irep *irep, size_t
return
MRB_DUMP_GENERAL_FAILURE
;
return
MRB_DUMP_GENERAL_FAILURE
;
}
}
fname
=
(
char
*
)
mrb_malloc
(
mrb
,
fname_len
+
1
);
fname
=
(
char
*
)
mrb_malloc
(
mrb
,
fname_len
+
1
);
if
(
fname
==
NULL
)
{
return
MRB_DUMP_GENERAL_FAILURE
;
}
memcpy
(
fname
,
bin
,
fname_len
);
memcpy
(
fname
,
bin
,
fname_len
);
fname
[
fname_len
]
=
'\0'
;
fname
[
fname_len
]
=
'\0'
;
bin
+=
fname_len
;
bin
+=
fname_len
;
...
@@ -233,9 +221,6 @@ read_lineno_record_1(mrb_state *mrb, const uint8_t *bin, mrb_irep *irep, size_t
...
@@ -233,9 +221,6 @@ read_lineno_record_1(mrb_state *mrb, const uint8_t *bin, mrb_irep *irep, size_t
return
MRB_DUMP_GENERAL_FAILURE
;
return
MRB_DUMP_GENERAL_FAILURE
;
}
}
lines
=
(
uint16_t
*
)
mrb_malloc
(
mrb
,
niseq
*
sizeof
(
uint16_t
));
lines
=
(
uint16_t
*
)
mrb_malloc
(
mrb
,
niseq
*
sizeof
(
uint16_t
));
if
(
lines
==
NULL
)
{
return
MRB_DUMP_GENERAL_FAILURE
;
}
for
(
i
=
0
;
i
<
niseq
;
i
++
)
{
for
(
i
=
0
;
i
<
niseq
;
i
++
)
{
lines
[
i
]
=
bin_to_uint16
(
bin
);
lines
[
i
]
=
bin_to_uint16
(
bin
);
bin
+=
sizeof
(
uint16_t
);
/* niseq */
bin
+=
sizeof
(
uint16_t
);
/* niseq */
...
@@ -543,9 +528,6 @@ read_lineno_record_file(mrb_state *mrb, FILE *fp, mrb_irep *irep)
...
@@ -543,9 +528,6 @@ read_lineno_record_file(mrb_state *mrb, FILE *fp, mrb_irep *irep)
return
MRB_DUMP_GENERAL_FAILURE
;
return
MRB_DUMP_GENERAL_FAILURE
;
}
}
ptr
=
mrb_malloc
(
mrb
,
buf_size
);
ptr
=
mrb_malloc
(
mrb
,
buf_size
);
if
(
!
ptr
)
{
return
MRB_DUMP_GENERAL_FAILURE
;
}
buf
=
(
uint8_t
*
)
ptr
;
buf
=
(
uint8_t
*
)
ptr
;
if
(
fread
(
&
buf
[
record_header_size
],
buf_size
-
record_header_size
,
1
,
fp
)
==
0
)
{
if
(
fread
(
&
buf
[
record_header_size
],
buf_size
-
record_header_size
,
1
,
fp
)
==
0
)
{
...
@@ -593,7 +575,6 @@ read_irep_record_file(mrb_state *mrb, FILE *fp)
...
@@ -593,7 +575,6 @@ read_irep_record_file(mrb_state *mrb, FILE *fp)
return
NULL
;
return
NULL
;
}
}
ptr
=
mrb_malloc
(
mrb
,
buf_size
);
ptr
=
mrb_malloc
(
mrb
,
buf_size
);
if
(
!
ptr
)
return
NULL
;
buf
=
(
uint8_t
*
)
ptr
;
buf
=
(
uint8_t
*
)
ptr
;
memcpy
(
buf
,
header
,
record_header_size
);
memcpy
(
buf
,
header
,
record_header_size
);
if
(
fread
(
&
buf
[
record_header_size
],
buf_size
-
record_header_size
,
1
,
fp
)
==
0
)
{
if
(
fread
(
&
buf
[
record_header_size
],
buf_size
-
record_header_size
,
1
,
fp
)
==
0
)
{
...
@@ -642,9 +623,6 @@ mrb_read_irep_file(mrb_state *mrb, FILE* fp)
...
@@ -642,9 +623,6 @@ mrb_read_irep_file(mrb_state *mrb, FILE* fp)
/* You don't need use SIZE_ERROR as buf_size is enough small. */
/* You don't need use SIZE_ERROR as buf_size is enough small. */
buf
=
(
uint8_t
*
)
mrb_malloc
(
mrb
,
buf_size
);
buf
=
(
uint8_t
*
)
mrb_malloc
(
mrb
,
buf_size
);
if
(
!
buf
)
{
return
NULL
;
}
if
(
fread
(
buf
,
buf_size
,
1
,
fp
)
==
0
)
{
if
(
fread
(
buf
,
buf_size
,
1
,
fp
)
==
0
)
{
mrb_free
(
mrb
,
buf
);
mrb_free
(
mrb
,
buf
);
return
NULL
;
return
NULL
;
...
...
src/proc.c
View file @
306b1d3c
...
@@ -196,9 +196,6 @@ mrb_init_proc(mrb_state *mrb)
...
@@ -196,9 +196,6 @@ mrb_init_proc(mrb_state *mrb)
mrb_irep
*
call_irep
=
(
mrb_irep
*
)
mrb_malloc
(
mrb
,
sizeof
(
mrb_irep
));
mrb_irep
*
call_irep
=
(
mrb_irep
*
)
mrb_malloc
(
mrb
,
sizeof
(
mrb_irep
));
static
const
mrb_irep
mrb_irep_zero
=
{
0
};
static
const
mrb_irep
mrb_irep_zero
=
{
0
};
if
(
call_irep
==
NULL
)
return
;
*
call_irep
=
mrb_irep_zero
;
*
call_irep
=
mrb_irep_zero
;
call_irep
->
flags
=
MRB_ISEQ_NO_FREE
;
call_irep
->
flags
=
MRB_ISEQ_NO_FREE
;
call_irep
->
iseq
=
call_iseq
;
call_irep
->
iseq
=
call_iseq
;
...
...
src/state.c
View file @
306b1d3c
...
@@ -78,7 +78,6 @@ mrb_alloca(mrb_state *mrb, size_t size)
...
@@ -78,7 +78,6 @@ mrb_alloca(mrb_state *mrb, size_t size)
struct
alloca_header
*
p
;
struct
alloca_header
*
p
;
p
=
(
struct
alloca_header
*
)
mrb_malloc
(
mrb
,
sizeof
(
struct
alloca_header
)
+
size
);
p
=
(
struct
alloca_header
*
)
mrb_malloc
(
mrb
,
sizeof
(
struct
alloca_header
)
+
size
);
if
(
p
==
NULL
)
return
NULL
;
p
->
next
=
mrb
->
mems
;
p
->
next
=
mrb
->
mems
;
mrb
->
mems
=
p
;
mrb
->
mems
=
p
;
return
(
void
*
)
p
->
buf
;
return
(
void
*
)
p
->
buf
;
...
...
src/variable.c
View file @
306b1d3c
...
@@ -46,11 +46,10 @@ iv_new(mrb_state *mrb)
...
@@ -46,11 +46,10 @@ iv_new(mrb_state *mrb)
iv_tbl
*
t
;
iv_tbl
*
t
;
t
=
mrb_malloc
(
mrb
,
sizeof
(
iv_tbl
));
t
=
mrb_malloc
(
mrb
,
sizeof
(
iv_tbl
));
if
(
t
)
{
t
->
size
=
0
;
t
->
size
=
0
;
t
->
rootseg
=
NULL
;
t
->
rootseg
=
NULL
;
t
->
last_len
=
0
;
t
->
last_len
=
0
;
}
return
t
;
return
t
;
}
}
...
...
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