]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.fastlz/native/jniWrapper.c
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.fastlz / native / jniWrapper.c
index 6f497627a2907606121c3e701714d46831dfcf18..a2abf9515861fe053f2b3bbfed773a90c73d3ae2 100644 (file)
@@ -1,89 +1,89 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
- * in Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-#include "fastlz.h"\r
-#include "lz4.h"\r
-#include <stdio.h>\r
-#include "jni.h"\r
-#include <string.h>\r
-#include <stdlib.h>\r
-\r
-JNIEXPORT jint JNICALL Java_org_simantics_fastlz_FastLZ_compress(JNIEnv* env, jclass clazz, \r
-                                                                 jobject input, jint inputOffset, jint length, \r
-                                                                 jobject output, jint outputOffset) {\r
-    void* inputAddress = (char*)(*env)->GetDirectBufferAddress(env, input) + inputOffset;\r
-    void* outputAddress = (char*)(*env)->GetDirectBufferAddress(env, output) + outputOffset;\r
-    return fastlz_compress(inputAddress, length, outputAddress);\r
-}\r
-\r
-JNIEXPORT jint JNICALL Java_org_simantics_fastlz_FastLZ_decompress(JNIEnv* env, jclass clazz, \r
-                                                                   jobject input, jint inputOffset, jint length, \r
-                                                                   jobject output, jint outputOffset, jint maxout) {\r
-    void* inputAddress = (char*)(*env)->GetDirectBufferAddress(env, input) + inputOffset;\r
-    void* outputAddress = (char*)(*env)->GetDirectBufferAddress(env, output) + outputOffset;\r
-    return fastlz_decompress(inputAddress, length, outputAddress, maxout);\r
-}\r
-\r
-#define INITIAL_SIZE 2000000\r
-\r
-JNIEXPORT jint JNICALL Java_org_simantics_fastlz_FastLZ_decompressCluster(JNIEnv* env, jclass clazz, jobject deflated, jint deflatedSize, jint inflatedSize, jobjectArray arrays) {\r
-\r
-       static char *inflateBuffer = 0;\r
-       static int inflateBufferSize = 0;\r
-\r
-       int ll, il, bl;\r
-\r
-       jlongArray longs;\r
-       jintArray ints;\r
-       jbyteArray bytes;\r
-\r
-       char *input = (char*)(*env)->GetDirectBufferAddress(env, deflated);\r
-       char *address;\r
-\r
-       if(inflateBufferSize < inflatedSize) {\r
-               if(!inflateBuffer) {\r
-                       if(inflatedSize < INITIAL_SIZE) inflatedSize = INITIAL_SIZE;\r
-                       inflateBuffer = malloc(inflatedSize);\r
-                       inflateBufferSize = inflatedSize;\r
-               } else {\r
-                       if(inflateBuffer) free(inflateBuffer);\r
-                       inflateBuffer = malloc(inflatedSize);\r
-                       inflateBufferSize = inflatedSize;\r
-               }\r
-       }\r
-\r
-       address = inflateBuffer;\r
-\r
-       fastlz_decompress(input, deflatedSize, inflateBuffer, inflateBufferSize);\r
-\r
-       ll = *(int *)address;\r
-       longs = (*env)->NewLongArray(env, ll);\r
-       (*env)->SetLongArrayRegion(env, longs, 0, ll, (const jlong *)(address + 4));\r
-       (*env)->SetObjectArrayElement(env, arrays, 0, longs);\r
-\r
-       address += 4 + 8 * ll;\r
-\r
-       il = *(int *)address;\r
-       ints = (*env)->NewIntArray(env, il);\r
-       (*env)->SetIntArrayRegion(env, ints, 0, il, (const jint *)(address + 4));\r
-       (*env)->SetObjectArrayElement(env, arrays, 1, ints);\r
-\r
-       address += 4 * il + 4;\r
-\r
-       bl = *(int *)address;\r
-       bytes = (*env)->NewByteArray(env, bl);\r
-       (*env)->SetByteArrayRegion(env, bytes, 0, bl, (const jbyte *)(address + 4));\r
-       (*env)->SetObjectArrayElement(env, arrays, 2, bytes);\r
-\r
-       return 0;\r
-\r
-}\r
-\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+#include "fastlz.h"
+#include "lz4.h"
+#include <stdio.h>
+#include "jni.h"
+#include <string.h>
+#include <stdlib.h>
+
+JNIEXPORT jint JNICALL Java_org_simantics_fastlz_FastLZ_compress(JNIEnv* env, jclass clazz, 
+                                                                 jobject input, jint inputOffset, jint length, 
+                                                                 jobject output, jint outputOffset) {
+    void* inputAddress = (char*)(*env)->GetDirectBufferAddress(env, input) + inputOffset;
+    void* outputAddress = (char*)(*env)->GetDirectBufferAddress(env, output) + outputOffset;
+    return fastlz_compress(inputAddress, length, outputAddress);
+}
+
+JNIEXPORT jint JNICALL Java_org_simantics_fastlz_FastLZ_decompress(JNIEnv* env, jclass clazz, 
+                                                                   jobject input, jint inputOffset, jint length, 
+                                                                   jobject output, jint outputOffset, jint maxout) {
+    void* inputAddress = (char*)(*env)->GetDirectBufferAddress(env, input) + inputOffset;
+    void* outputAddress = (char*)(*env)->GetDirectBufferAddress(env, output) + outputOffset;
+    return fastlz_decompress(inputAddress, length, outputAddress, maxout);
+}
+
+#define INITIAL_SIZE 2000000
+
+JNIEXPORT jint JNICALL Java_org_simantics_fastlz_FastLZ_decompressCluster(JNIEnv* env, jclass clazz, jobject deflated, jint deflatedSize, jint inflatedSize, jobjectArray arrays) {
+
+       static char *inflateBuffer = 0;
+       static int inflateBufferSize = 0;
+
+       int ll, il, bl;
+
+       jlongArray longs;
+       jintArray ints;
+       jbyteArray bytes;
+
+       char *input = (char*)(*env)->GetDirectBufferAddress(env, deflated);
+       char *address;
+
+       if(inflateBufferSize < inflatedSize) {
+               if(!inflateBuffer) {
+                       if(inflatedSize < INITIAL_SIZE) inflatedSize = INITIAL_SIZE;
+                       inflateBuffer = malloc(inflatedSize);
+                       inflateBufferSize = inflatedSize;
+               } else {
+                       if(inflateBuffer) free(inflateBuffer);
+                       inflateBuffer = malloc(inflatedSize);
+                       inflateBufferSize = inflatedSize;
+               }
+       }
+
+       address = inflateBuffer;
+
+       fastlz_decompress(input, deflatedSize, inflateBuffer, inflateBufferSize);
+
+       ll = *(int *)address;
+       longs = (*env)->NewLongArray(env, ll);
+       (*env)->SetLongArrayRegion(env, longs, 0, ll, (const jlong *)(address + 4));
+       (*env)->SetObjectArrayElement(env, arrays, 0, longs);
+
+       address += 4 + 8 * ll;
+
+       il = *(int *)address;
+       ints = (*env)->NewIntArray(env, il);
+       (*env)->SetIntArrayRegion(env, ints, 0, il, (const jint *)(address + 4));
+       (*env)->SetObjectArrayElement(env, arrays, 1, ints);
+
+       address += 4 * il + 4;
+
+       bl = *(int *)address;
+       bytes = (*env)->NewByteArray(env, bl);
+       (*env)->SetByteArrayRegion(env, bytes, 0, bl, (const jbyte *)(address + 4));
+       (*env)->SetObjectArrayElement(env, arrays, 2, bytes);
+
+       return 0;
+
+}
+