memory leak in JNI write functions fixed
git-svn-id: https://svn.code.sf.net/p/libusbjava/code/trunk@270 94ad28fe-ef68-46b1-9651-e7ae4fcf1c4c
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?fileVersion 4.0.0?>
|
||||
|
||||
<cproject>
|
||||
@@ -47,11 +47,7 @@
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.pathentry">
|
||||
<pathentry kind="src" path=""/>
|
||||
<pathentry kind="out" path=""/>
|
||||
<pathentry kind="con" path="org.eclipse.cdt.make.core.DISCOVERED_SCANNER_INFO"/>
|
||||
</storageModule>
|
||||
|
||||
<storageModule buildSystemId="org.eclipse.cdt.core.defaultConfigDataProvider" id="converted.config.1096271423" moduleId="org.eclipse.cdt.core.settings" name="convertedConfig">
|
||||
<externalSettings/>
|
||||
<extensions>
|
||||
@@ -59,6 +55,13 @@
|
||||
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.pathentry">
|
||||
<pathentry kind="src" path=""/>
|
||||
<pathentry kind="out" path=""/>
|
||||
<pathentry kind="con" path="org.eclipse.cdt.make.core.DISCOVERED_SCANNER_INFO"/>
|
||||
</storageModule>
|
||||
</cconfiguration>
|
||||
</storageModule>
|
||||
</cproject>
|
||||
|
||||
@@ -665,9 +665,10 @@ JNIEXPORT jint JNICALL Java_ch_ntb_usb_LibusbJava_usb_1control_1msg
|
||||
{
|
||||
clearLibusbJavaError();
|
||||
jbyte *bytes = env->GetByteArrayElements(jbytes, NULL);
|
||||
int retVal = usb_control_msg((usb_dev_handle *) dev_handle, requesttype, request, value, index, (char *) bytes, size, timeout);
|
||||
int num_bytes = usb_control_msg((usb_dev_handle *) dev_handle, requesttype, request, value, index, (char *) bytes, size, timeout);
|
||||
env->SetByteArrayRegion(jbytes, 0, size, bytes);
|
||||
return retVal;
|
||||
env->ReleaseByteArrayElements(jbytes, bytes, 0);
|
||||
return num_bytes;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -746,7 +747,9 @@ JNIEXPORT jint JNICALL Java_ch_ntb_usb_LibusbJava_usb_1bulk_1write
|
||||
{
|
||||
clearLibusbJavaError();
|
||||
jbyte *bytes = env->GetByteArrayElements(jbytes, NULL);
|
||||
return usb_bulk_write((usb_dev_handle *) dev_handle, ep, (char *) bytes, size, timeout);
|
||||
int num_bytes = usb_bulk_write((usb_dev_handle *) dev_handle, ep, (char *) bytes, size, timeout);
|
||||
env->ReleaseByteArrayElements(jbytes, bytes, 0);
|
||||
return num_bytes;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -759,11 +762,11 @@ JNIEXPORT jint JNICALL Java_ch_ntb_usb_LibusbJava_usb_1bulk_1read
|
||||
{
|
||||
clearLibusbJavaError();
|
||||
char *bytes = (char *) malloc(size * sizeof(char));
|
||||
int retVal = usb_bulk_read((usb_dev_handle *) dev_handle, ep, bytes, size, timeout);
|
||||
if (!bytes) { return retVal; }
|
||||
int num_bytes = usb_bulk_read((usb_dev_handle *) dev_handle, ep, bytes, size, timeout);
|
||||
if (!bytes) { return num_bytes; }
|
||||
env->SetByteArrayRegion(jbytes, 0, size, (jbyte *) bytes);
|
||||
free(bytes);
|
||||
return retVal;
|
||||
return num_bytes;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -776,7 +779,9 @@ JNIEXPORT jint JNICALL Java_ch_ntb_usb_LibusbJava_usb_1interrupt_1write
|
||||
{
|
||||
clearLibusbJavaError();
|
||||
jbyte *bytes = env->GetByteArrayElements(jbytes, NULL);
|
||||
return usb_interrupt_write((usb_dev_handle *) dev_handle, ep, (char *) bytes, size, timeout);
|
||||
int num_bytes = usb_interrupt_write((usb_dev_handle *) dev_handle, ep, (char *) bytes, size, timeout);
|
||||
env->ReleaseByteArrayElements(jbytes, bytes, 0);
|
||||
return num_bytes;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -789,11 +794,11 @@ JNIEXPORT jint JNICALL Java_ch_ntb_usb_LibusbJava_usb_1interrupt_1read
|
||||
{
|
||||
clearLibusbJavaError();
|
||||
char *bytes = (char *) malloc(size * sizeof(char));
|
||||
int retVal = usb_interrupt_read((usb_dev_handle *) dev_handle, ep, bytes, size, timeout);
|
||||
if (!bytes) { return retVal; }
|
||||
int num_bytes = usb_interrupt_read((usb_dev_handle *) dev_handle, ep, bytes, size, timeout);
|
||||
if (!bytes) { return num_bytes; }
|
||||
env->SetByteArrayRegion(jbytes, 0, size, (jbyte *) bytes);
|
||||
free(bytes);
|
||||
return retVal;
|
||||
return num_bytes;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -20,7 +20,7 @@ BEGIN
|
||||
VALUE "FileDescription", RC_PRODUCT_STR
|
||||
VALUE "FileVersion", RC_VERSION_STR
|
||||
VALUE "InternalName", RC_FILE_NAME_STR
|
||||
VALUE "LegalCopyright", "2005 spandi@users.sourceforge.net"
|
||||
VALUE "LegalCopyright", "2008 spandi@users.sourceforge.net"
|
||||
VALUE "OriginalFilename",RC_FILE_NAME_STR
|
||||
VALUE "ProductName", RC_PRODUCT_STR
|
||||
VALUE "ProductVersion", RC_VERSION_STR
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
#define RC_FILE_SUB_TYPE VFT2_UNKNOWN
|
||||
#define RC_PRODUCT_STR "Java LibUsb-Win32 wrapper - DLL"
|
||||
#define RC_FILE_NAME_STR "LibusbJava.dll"
|
||||
#define RC_VERSION_STR "0.2.3.0"
|
||||
#define RC_VERSION_STR "0.2.4.0"
|
||||
|
||||
#include "common.rc"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# NOTE: if the version is changed -> change the define in resource.rc
|
||||
version.major=0
|
||||
version.minor=2
|
||||
version.micro=3
|
||||
version.micro=4
|
||||
version.nano=0
|
||||
Reference in New Issue
Block a user