You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2011/04/14 17:26:52 UTC
svn commit: r1092339 - in /commons/sandbox/runtime/trunk/src/main:
java/org/apache/commons/runtime/Memory.java native/shared/memory.c
Author: mturk
Date: Thu Apr 14 15:26:51 2011
New Revision: 1092339
URL: http://svn.apache.org/viewvc?rev=1092339&view=rev
Log:
Add very dangerous Memory.free method. Meant to be used internally only
Modified:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Memory.java
commons/sandbox/runtime/trunk/src/main/native/shared/memory.c
Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Memory.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Memory.java?rev=1092339&r1=1092338&r2=1092339&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Memory.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Memory.java Thu Apr 14 15:26:51 2011
@@ -129,6 +129,17 @@ public final class Memory
}
/**
+ * Frees a memory block.
+ *
+ * <p>
+ * <b>Warning:</b>Using this method improperly may crash the running JVM.
+ * </p>
+ *
+ * @param address Previously allocated memory block to be freed.
+ */
+ public static native void free(long address);
+
+ /**
* Allocates {@code size} bytes and returns a {@link Pointer}
* to the allocated memory. The memory is not cleared.
*
Modified: commons/sandbox/runtime/trunk/src/main/native/shared/memory.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/memory.c?rev=1092339&r1=1092338&r2=1092339&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/memory.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/memory.c Thu Apr 14 15:26:51 2011
@@ -311,6 +311,11 @@ ACR_JNI_EXPORT(jlong, Memory, realloc0)(
return P2J(mem);
}
+ACR_JNI_EXPORT(void, Memory, free)(JNI_STDARGS, jlong ptr)
+{
+ AcrFree(J2P(ptr, void *));
+}
+
ACR_JNI_EXPORT(jint, Memory, peek0)(JNI_STDARGS, jlong a)
{
return *(J2P(a, unsigned char *));