summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-bin-debugger/tools/mrdb/apilist.c
diff options
context:
space:
mode:
authorTatsuhiko Kubo <[email protected]>2015-01-01 05:12:41 +0900
committerTatsuhiko Kubo <[email protected]>2015-01-01 05:12:41 +0900
commit606095f2fe955f61aea88cd2e7ed9a6387eecaac (patch)
tree45718b550f362c8cf996152f6700e0da51472bce /mrbgems/mruby-bin-debugger/tools/mrdb/apilist.c
parent4046368ef34e9062dee406ae986961010ffb313f (diff)
downloadmruby-606095f2fe955f61aea88cd2e7ed9a6387eecaac.tar.gz
mruby-606095f2fe955f61aea88cd2e7ed9a6387eecaac.zip
Remove redundant NULL checks for mrb_malloc().
Diffstat (limited to 'mrbgems/mruby-bin-debugger/tools/mrdb/apilist.c')
-rwxr-xr-xmrbgems/mruby-bin-debugger/tools/mrdb/apilist.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/mrbgems/mruby-bin-debugger/tools/mrdb/apilist.c b/mrbgems/mruby-bin-debugger/tools/mrdb/apilist.c
index 734f03f0a..999bd6328 100755
--- a/mrbgems/mruby-bin-debugger/tools/mrdb/apilist.c
+++ b/mrbgems/mruby-bin-debugger/tools/mrdb/apilist.c
@@ -48,15 +48,15 @@ build_path(mrb_state *mrb, const char *dir, const char *base)
len += strlen(dir) + strlen("/");
}
- if ((path = mrb_malloc(mrb, len)) != NULL) {
- memset(path, 0, len);
+ path = mrb_malloc(mrb, len);
+ memset(path, 0, len);
- if (strcmp(dir, ".")) {
- strcat(path, dir);
- strcat(path, "/");
- }
- strcat(path, base);
+ if (strcmp(dir, ".")) {
+ strcat(path, dir);
+ strcat(path, "/");
}
+ strcat(path, base);
+
return path;
}
@@ -73,10 +73,10 @@ dirname(mrb_state *mrb, const char *path)
p = strrchr(path, '/');
len = p != NULL ? p - path : strlen(path);
- if ((dir = mrb_malloc(mrb, len + 1)) != NULL) {
- strncpy(dir, path, len);
- dir[len] = '\0';
- }
+ dir = mrb_malloc(mrb, len + 1);
+ strncpy(dir, path, len);
+ dir[len] = '\0';
+
return dir;
}
@@ -85,9 +85,7 @@ source_file_new(mrb_state *mrb, mrb_debug_context *dbg, char *filename)
{
source_file *file = NULL;
- if ((file = mrb_malloc(mrb, sizeof(source_file))) == NULL) {
- return NULL;
- }
+ file = mrb_malloc(mrb, sizeof(source_file));
memset(file, '\0', sizeof(source_file));
file->fp = fopen(filename, "rb");