diff options
author | Nick Pelly <npelly@google.com> | 2010-11-02 19:57:15 -0500 |
---|---|---|
committer | Nick Pelly <npelly@google.com> | 2010-11-02 21:36:40 -0500 |
commit | d6d37f92a925d986a1abf9c296e4f67a0403e354 (patch) | |
tree | 4387f7dbb953fac69d1fe15903825e74f00d2e08 /jni/com_android_nfc_NativeLlcpSocket.cpp | |
parent | 7fa45a3567dabab6125279ea4566780f04d57a4f (diff) | |
download | packages_apps_nfc-d6d37f92a925d986a1abf9c296e4f67a0403e354.zip packages_apps_nfc-d6d37f92a925d986a1abf9c296e4f67a0403e354.tar.gz packages_apps_nfc-d6d37f92a925d986a1abf9c296e4f67a0403e354.tar.bz2 |
Use malloc to allocate semaphores for easier memory corruption detection.
Change-Id: I9741b2527914992ab710c405d869f0ac6273f468
Signed-off-by: Nick Pelly <npelly@google.com>
Diffstat (limited to 'jni/com_android_nfc_NativeLlcpSocket.cpp')
-rw-r--r-- | jni/com_android_nfc_NativeLlcpSocket.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/jni/com_android_nfc_NativeLlcpSocket.cpp b/jni/com_android_nfc_NativeLlcpSocket.cpp index 112dda0..90aec16 100644 --- a/jni/com_android_nfc_NativeLlcpSocket.cpp +++ b/jni/com_android_nfc_NativeLlcpSocket.cpp @@ -18,7 +18,7 @@ #include "com_android_nfc.h" -static sem_t nfc_jni_llcp_sem; +static sem_t *nfc_jni_llcp_sem; static NFCSTATUS nfc_jni_cb_status = NFCSTATUS_FAILED; namespace android { @@ -36,7 +36,7 @@ static void nfc_jni_disconnect_callback(void* pContext, nfc_jni_cb_status = status; - sem_post(&nfc_jni_llcp_sem); + sem_post(nfc_jni_llcp_sem); } @@ -84,7 +84,7 @@ static void nfc_jni_connect_callback(void* pContext, uint8_t nErrCode, NFCSTATUS } } - sem_post(&nfc_jni_llcp_sem); + sem_post(nfc_jni_llcp_sem); } @@ -99,7 +99,7 @@ static void nfc_jni_receive_callback(void* pContext, NFCSTATUS status) nfc_jni_cb_status = status; - sem_post(&nfc_jni_llcp_sem); + sem_post(nfc_jni_llcp_sem); } static void nfc_jni_send_callback(void *pContext, NFCSTATUS status) @@ -110,7 +110,7 @@ static void nfc_jni_send_callback(void *pContext, NFCSTATUS status) nfc_jni_cb_status = status; - sem_post(&nfc_jni_llcp_sem); + sem_post(nfc_jni_llcp_sem); } /* @@ -140,7 +140,7 @@ static jboolean com_android_nfc_NativeLlcpSocket_doConnect(JNIEnv *e, jobject o, LOGD("phLibNfc_Llcp_Connect(%d) returned 0x%04x[%s]", nSap, ret, nfc_jni_get_status_name(ret)); /* Wait for callback response */ - if(sem_wait(&nfc_jni_llcp_sem) == -1) + if(sem_wait(nfc_jni_llcp_sem) == -1) return FALSE; if(nfc_jni_cb_status == NFCSTATUS_SUCCESS) @@ -184,7 +184,7 @@ static jboolean com_android_nfc_NativeLlcpSocket_doConnectBy(JNIEnv *e, jobject LOGD("phLibNfc_Llcp_ConnectByUri() returned 0x%04x[%s]", ret, nfc_jni_get_status_name(ret)); /* Wait for callback response */ - if(sem_wait(&nfc_jni_llcp_sem) == -1) + if(sem_wait(nfc_jni_llcp_sem) == -1) return FALSE; if(nfc_jni_cb_status == NFCSTATUS_SUCCESS) @@ -246,7 +246,7 @@ static jboolean com_android_nfc_NativeLlcpSocket_doSend(JNIEnv *e, jobject o, jb LOGD("phLibNfc_Llcp_Send() returned 0x%04x[%s]", ret, nfc_jni_get_status_name(ret)); /* Wait for callback response */ - if(sem_wait(&nfc_jni_llcp_sem) == -1) + if(sem_wait(nfc_jni_llcp_sem) == -1) return FALSE; @@ -289,7 +289,7 @@ static jint com_android_nfc_NativeLlcpSocket_doReceive(JNIEnv *e, jobject o, jby LOGD("phLibNfc_Llcp_Recv() returned 0x%04x[%s]", ret, nfc_jni_get_status_name(ret)); /* Wait for callback response (happen if status is either SUCCESS or PENDING) */ - if(sem_wait(&nfc_jni_llcp_sem) == -1) + if(sem_wait(nfc_jni_llcp_sem) == -1) { return 0; } @@ -387,7 +387,8 @@ static JNINativeMethod gMethods[] = int register_com_android_nfc_NativeLlcpSocket(JNIEnv *e) { - if(sem_init(&nfc_jni_llcp_sem, 0, 0) == -1) + nfc_jni_llcp_sem = (sem_t *)malloc(sizeof(sem_t)); + if(sem_init(nfc_jni_llcp_sem, 0, 0) == -1) return -1; return jniRegisterNativeMethods(e, |