Skip to content

Commit

Permalink
Use free instead of XXH32_result.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpountz committed Dec 17, 2012
1 parent 54a51f9 commit da8bef9
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 11 deletions.
3 changes: 1 addition & 2 deletions .settings/org.eclipse.jdt.core.prefs
@@ -1,4 +1,3 @@
#Tue Jul 17 16:36:09 CEST 2012
eclipse.preferences.version=1
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
Expand Down Expand Up @@ -80,7 +79,7 @@ org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false
org.eclipse.jdt.core.formatter.indentation.size=8
org.eclipse.jdt.core.formatter.indentation.size=4
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert
Expand Down
5 changes: 1 addition & 4 deletions README
Expand Up @@ -44,10 +44,7 @@ http://code.google.com/p/xxhash/.
Similarly to LZ4, 3 implementations are available: JNI bindings, pure Java port
and pure Java port that uses sun.misc.Unsafe.

Please note that the 3 implementations will return the same result for the same
input on the same machine but the hash will differ on a machine of the opposite
endianess.

All implementations return the same result for the same input bytes.

Build
-----
Expand Down
8 changes: 3 additions & 5 deletions src/java/net/jpountz/xxhash/StreamingXXHash32JNI.java
Expand Up @@ -36,7 +36,7 @@ private void checkState() {
@Override
public void reset() {
checkState();
XXHashJNI.XXH32_result(state);
XXHashJNI.XXH32_free(state);
state = XXHashJNI.XXH32_init(seed);
}

Expand All @@ -56,10 +56,8 @@ public void update(byte[] bytes, int off, int len) {
protected void finalize() throws Throwable {
super.finalize();
// free memory
if (state != 0) {
XXHashJNI.XXH32_result(state);
state = 0;
}
XXHashJNI.XXH32_free(state);
state = 0;
}

}
1 change: 1 addition & 0 deletions src/java/net/jpountz/xxhash/XXHashJNI.java
Expand Up @@ -33,5 +33,6 @@ enum XXHashJNI {
static native void XXH32_feed(long state, byte[] input, int offset, int len);
static native int XXH32_getIntermediateResult(long state);
static native int XXH32_result(long state);
static native void XXH32_free(long state);

}
13 changes: 13 additions & 0 deletions src/jni/net_jpountz_xxhash_XXHashJNI.c
Expand Up @@ -15,6 +15,7 @@
* limitations under the License.
*/

#include <stdlib.h>
#include "xxhash.h"
#include "net_jpountz_xxhash_XXHashJNI.h"

Expand Down Expand Up @@ -111,3 +112,15 @@ JNIEXPORT jint JNICALL Java_net_jpountz_xxhash_XXHashJNI_XXH32_1result

}

/*
* Class: net_jpountz_xxhash_XXHashJNI
* Method: XXH32_free
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_net_jpountz_xxhash_XXHashJNI_XXH32_1free
(JNIEnv *env, jclass cls, jlong state) {

free((void*) state);

}

0 comments on commit da8bef9

Please sign in to comment.