summaryrefslogtreecommitdiffstats
path: root/luni
diff options
context:
space:
mode:
authorLajos Molnar <lajos@google.com>2014-05-19 17:16:23 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-05-19 17:16:23 +0000
commit9f977fa97630092c831d52a15d24f87c7e87c876 (patch)
treee769818c7bf7e770d82bf58fd89f20c63a391520 /luni
parent130299220f51321883ca637adb6fadbd369cc710 (diff)
parent6b9a7d3e754ab5588aee4ae54579cf6838bb7e0c (diff)
downloadlibcore-9f977fa97630092c831d52a15d24f87c7e87c876.zip
libcore-9f977fa97630092c831d52a15d24f87c7e87c876.tar.gz
libcore-9f977fa97630092c831d52a15d24f87c7e87c876.tar.bz2
am 6b9a7d3e: Merge "DirectByteBuffer: allow 0-size MappedByteBuffers starting at NULL"
* commit '6b9a7d3e754ab5588aee4ae54579cf6838bb7e0c': DirectByteBuffer: allow 0-size MappedByteBuffers starting at NULL
Diffstat (limited to 'luni')
-rw-r--r--luni/src/main/java/java/nio/MemoryBlock.java5
-rw-r--r--luni/src/test/java/libcore/java/nio/BufferTest.java2
2 files changed, 5 insertions, 2 deletions
diff --git a/luni/src/main/java/java/nio/MemoryBlock.java b/luni/src/main/java/java/nio/MemoryBlock.java
index a619b8d..b62e3c6 100644
--- a/luni/src/main/java/java/nio/MemoryBlock.java
+++ b/luni/src/main/java/java/nio/MemoryBlock.java
@@ -95,6 +95,7 @@ class MemoryBlock {
protected long address;
protected final long size;
private boolean accessible;
+ private boolean freed;
public static MemoryBlock mmap(FileDescriptor fd, long offset, long size, MapMode mapMode) throws IOException {
if (size == 0) {
@@ -140,6 +141,7 @@ class MemoryBlock {
this.address = address;
this.size = size;
accessible = true;
+ freed = false;
}
// Used to support array/arrayOffset/hasArray for direct buffers.
@@ -149,10 +151,11 @@ class MemoryBlock {
public void free() {
address = 0;
+ freed = true;
}
public boolean isFreed() {
- return address == 0;
+ return freed;
}
public boolean isAccessible() {
diff --git a/luni/src/test/java/libcore/java/nio/BufferTest.java b/luni/src/test/java/libcore/java/nio/BufferTest.java
index de4e0f1..613c6fa 100644
--- a/luni/src/test/java/libcore/java/nio/BufferTest.java
+++ b/luni/src/test/java/libcore/java/nio/BufferTest.java
@@ -731,7 +731,7 @@ public class BufferTest extends TestCase {
Class<?> c = Class.forName("java.nio.DirectByteBuffer");
Constructor<?> ctor = c.getDeclaredConstructor(long.class, int.class);
ctor.setAccessible(true);
- ByteBuffer bb = (ByteBuffer) ctor.newInstance(1, 0);
+ ByteBuffer bb = (ByteBuffer) ctor.newInstance(0, 0);
try {
bb.array();