Skip to content

Commit

Permalink
[api] Take an array instead of an object arg, for simplicity.
Browse files Browse the repository at this point in the history
  • Loading branch information
AvianFlu committed May 16, 2012
1 parent e35487c commit 3da5dcd
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions src/prefork.cc
Expand Up @@ -11,18 +11,12 @@ using namespace node;
static Handle<Value> Prefork(const Arguments& args) {
HandleScope scope;

int stdio_fds[3] = { -1, -1, -1 };
// Take the options object out of args[0]
Local<Object> js_options = args[0]->ToObject();
// Trying to ->Get() properties of empty objects will segfault.
if (!js_options.IsEmpty()) {
Local<Value> custom_fds_v = js_options->Get(String::NewSymbol("customFds"));
if (!custom_fds_v.IsEmpty() && custom_fds_v->IsArray()) {
Local<Array> custom_fds = Local<Array>::Cast(custom_fds_v);
int i;
for(i = 0; i < 3; i++) {
stdio_fds[i] = custom_fds->Get(i)->Int32Value();
}
int i, stdio_fds[3] = { -1, -1, -1 };

if (!args[0].IsEmpty() && args[0]->IsArray()) {
Local<Array> custom_fds = Local<Array>::Cast(args[0]);
for(i = 0; i < 3; i++) {
stdio_fds[i] = custom_fds->Get(i)->Int32Value();
}
}

Expand Down

0 comments on commit 3da5dcd

Please sign in to comment.