From b44f5122fd920011bfd820f1df48fcaa966cba39 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Thu, 19 Sep 2019 00:13:42 -0400 Subject: [PATCH] Pass int directly as pointer --- native/jni/core/daemon.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/native/jni/core/daemon.cpp b/native/jni/core/daemon.cpp index 4ccb562fe..41dc7d97c 100644 --- a/native/jni/core/daemon.cpp +++ b/native/jni/core/daemon.cpp @@ -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(args); struct ucred credential; get_client_cred(client, &credential); @@ -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(client)); } }