Browse Source

Remove `if (pointer == NULL)` after allocations with `new`.

I'm still learning C++.
v0.7.4-release
Ryan 16 years ago
parent
commit
fd392d0a50
  1. 5
      src/file.cc
  2. 8
      src/net.cc
  3. 4
      src/timer.cc

5
src/file.cc

@ -450,10 +450,7 @@ Handle<Value>
File::New(const Arguments& args) File::New(const Arguments& args)
{ {
HandleScope scope; HandleScope scope;
File *file = new File(args.Holder()); new File(args.Holder());
if(file == NULL)
return Undefined(); // XXX raise error?
return args.This(); return args.This();
} }

8
src/net.cc

@ -54,9 +54,7 @@ Server::New (const Arguments& args)
if (args.Length() > 0 && args[0]->IsNumber()) if (args.Length() > 0 && args[0]->IsNumber())
backlog = args[0]->IntegerValue(); backlog = args[0]->IntegerValue();
Server *server = new Server(args.Holder(), backlog); new Server(args.Holder(), backlog);
if(server == NULL)
return Undefined(); // XXX raise error?
return args.This(); return args.This();
} }
@ -165,9 +163,7 @@ Socket::New(const Arguments& args)
} }
} }
Socket *s = new Socket(args.Holder(), timeout); new Socket(args.Holder(), timeout);
if(s == NULL)
return Undefined(); // XXX raise error?
return args.This(); return args.This();
} }

4
src/timer.cc

@ -68,9 +68,9 @@ Timer::New (const Arguments& args)
ev_tstamp after = (double)(args[1]->IntegerValue()) / 1000.0; ev_tstamp after = (double)(args[1]->IntegerValue()) / 1000.0;
ev_tstamp repeat = (double)(args[2]->IntegerValue()) / 1000.0; ev_tstamp repeat = (double)(args[2]->IntegerValue()) / 1000.0;
Timer *timer = new Timer(args.Holder(), callback, after, repeat); new Timer(args.Holder(), callback, after, repeat);
return scope.Close(timer->handle_); return args.This();
} }
Handle<Value> Handle<Value>

Loading…
Cancel
Save