commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r786150 - in /commons/sandbox/runtime/trunk/src: main/java/org/apache/commons/runtime/Memory.java test/org/apache/commons/runtime/TestMemory.java
Date Thu, 18 Jun 2009 16:26:51 GMT
Author: mturk
Date: Thu Jun 18 16:26:51 2009
New Revision: 786150

URL: http://svn.apache.org/viewvc?rev=786150&view=rev
Log:
Rename array() to asByteArray()

Modified:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Memory.java
    commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestMemory.java

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=786150&r1=786149&r2=786150&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
Jun 18 16:26:51 2009
@@ -136,9 +136,8 @@
     {
         if (size < 1L)
             throw new IllegalArgumentException();
-        synchronized (ptr) {
-            realloc0(ptr, size);
-        }
+
+        realloc0(ptr, size);
     }
 
     public static native Pointer slice0(Pointer src, long offset, long size)
@@ -166,9 +165,8 @@
             throw new NullPointerException();
         if (offset < 0L || size < 1L)
             throw new IllegalArgumentException();
-        synchronized (src) {
-            return slice0(src, offset, size);
-        }
+
+        return slice0(src, offset, size);
     }
 
     public static native Pointer dup0(Pointer src, long offset, long size)
@@ -200,9 +198,7 @@
         if (offset < 0L || size < 1L)
             throw new IllegalArgumentException();
 
-        synchronized (src) {
-            return dup0(src, offset, size);
-        }    
+        return dup0(src, offset, size);
     }
 
     public static native void copy0(Pointer src, long srcPos, Pointer dst,
@@ -246,11 +242,7 @@
         if (length < 1L)
             throw new IllegalArgumentException();
 
-        synchronized (src) {
-            synchronized (dst) {
-                copy0(src, srcPos, dst, dstPos, length);
-            }
-        }        
+        copy0(src, srcPos, dst, dstPos, length);
     }
 
     public static native void move0(Pointer src, long srcPos, Pointer dst,
@@ -293,11 +285,7 @@
         if (length < 1L)
             throw new IllegalArgumentException();
 
-        synchronized (src) {
-            synchronized (dst) {
-                move0(src, srcPos, dst, dstPos, length);
-            }
-        }        
+        move0(src, srcPos, dst, dstPos, length);
     }
 
     public static native void clear0(Pointer ptr, long offset, long length)
@@ -326,9 +314,7 @@
         if (offset < 0L || length < 1L)
             throw new IllegalArgumentException();
             
-        synchronized (ptr) {
-            clear0(ptr, offset, length);
-        }
+        clear0(ptr, offset, length);
     }
 
     public static native void set0(Pointer ptr, long offset, long length, int val)
@@ -358,9 +344,7 @@
         if (offset < 0L || length < 1L)
             throw new IllegalArgumentException();
             
-        synchronized (ptr) {
-            set0(ptr, offset, length, val);
-        }
+        set0(ptr, offset, length, val);
     }
 
     private static native byte[] array0(Pointer ptr, long offset, int length)
@@ -381,17 +365,15 @@
      * @throws NullPointerException if {@code ptr} is {@code null}.
      * @throws OutOfMemoryError if memory cannot be dipicated.
      */
-    public static byte[] array(Pointer ptr, long offset, int length)
+    public static byte[] asByteArray(Pointer ptr, long offset, int length)
         throws IndexOutOfBoundsException, IllegalArgumentException,
                NullPointerException, OutOfMemoryError
     {
         if (ptr == null || ptr.IsNull())
             throw new NullPointerException();
-        if (offset < 0L || length < 1L)
+        if (offset < 0L || length < 1)
             throw new IllegalArgumentException();
             
-        synchronized (ptr) {
-            return array0(ptr, offset, length);
-        }
+        return array0(ptr, offset, length);
     }
 }

Modified: commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestMemory.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestMemory.java?rev=786150&r1=786149&r2=786150&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestMemory.java (original)
+++ commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestMemory.java Thu
Jun 18 16:26:51 2009
@@ -182,13 +182,13 @@
         dst.free();
     }
 
-    public void testArray()
+    public void testByteArray()
         throws Throwable
     {
         Pointer p = Memory.calloc(1000);
         assertNotNull("Pointer", p);
         Memory.set(p, 0, 1000, 0xFF);
-        byte[] b = Memory.array(p, 0, 1000);
+        byte[] b = Memory.asByteArray(p, 0, 1000);
         assertNotNull("Array", b);
         assertEquals("Length", 1000, b.length);
         assertEquals("Value", (byte)0xFF, b[0]);



Mime
View raw message