Skip to content

Commit

Permalink
Pass int directly as pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
topjohnwu committed Sep 19, 2019
1 parent 1798173 commit b44f512
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions native/jni/core/daemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ static void remove_modules() {
}

static void *request_handler(void *args) {
int client = *((int *) args);
delete (int *) args;
int client = reinterpret_cast<intptr_t>(args);

struct ucred credential;
get_client_cred(client, &credential);
Expand Down Expand Up @@ -173,9 +172,8 @@ static void main_daemon() {

// Loop forever to listen for requests
for (;;) {
int *client = new int;
*client = xaccept4(fd, nullptr, nullptr, SOCK_CLOEXEC);
new_daemon_thread(request_handler, client);
int client = xaccept4(fd, nullptr, nullptr, SOCK_CLOEXEC);
new_daemon_thread(request_handler, reinterpret_cast<void*>(client));
}
}

Expand Down

0 comments on commit b44f512

Please sign in to comment.