/[classpath]/classpath/java/nio/DirectByteBufferImpl.java
ViewVC logotype

Diff of /classpath/java/nio/DirectByteBufferImpl.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.11.2.1 by gnu_andrew, Sun Jan 16 02:14:48 2005 UTC revision 1.11.2.2 by gnu_andrew, Sun Jan 16 15:15:12 2005 UTC
# Line 42  import gnu.classpath.RawData; Line 42  import gnu.classpath.RawData;
42    
43  abstract class DirectByteBufferImpl extends ByteBuffer  abstract class DirectByteBufferImpl extends ByteBuffer
44  {  {
45    /** The owner is used to keep alive the object that actually owns the    /**
46      * memory. There are three possibilities:     * The owner is used to keep alive the object that actually owns the
47      *  1) owner == this: We allocated the memory and we should free it,     * memory. There are three possibilities:
48      *                    but *only* in finalize (if we've been sliced     *  1) owner == this: We allocated the memory and we should free it,
49      *                    other objects will also have access to the     *                    but *only* in finalize (if we've been sliced
50      *                    memory).     *                    other objects will also have access to the
51      *  2) owner == null: The byte buffer was created thru     *                    memory).
52      *                    JNI.NewDirectByteBuffer. The JNI code is     *  2) owner == null: The byte buffer was created thru
53      *                    responsible for freeing the memory.     *                    JNI.NewDirectByteBuffer. The JNI code is
54      *  3) owner == some other object: The other object allocated the     *                    responsible for freeing the memory.
55      *                                 memory and should free it.     *  3) owner == some other object: The other object allocated the
56      */     *                                 memory and should free it.
57       */
58    private final Object owner;    private final Object owner;
   final RawData address;  
59    
60    final static class ReadOnly extends DirectByteBufferImpl    static final class ReadOnly extends DirectByteBufferImpl
61    {    {
62      ReadOnly(Object owner, RawData address,      ReadOnly(Object owner, RawData address,
63               int capacity, int limit,               int capacity, int limit,
# Line 82  abstract class DirectByteBufferImpl exte Line 82  abstract class DirectByteBufferImpl exte
82      }      }
83    }    }
84    
85    final static class ReadWrite extends DirectByteBufferImpl    static final class ReadWrite extends DirectByteBufferImpl
86    {    {
87      ReadWrite(int capacity)      ReadWrite(int capacity)
88      {      {
# Line 186  abstract class DirectByteBufferImpl exte Line 186  abstract class DirectByteBufferImpl exte
186        
187    public ByteBuffer compact()    public ByteBuffer compact()
188    {    {
189        checkIfReadOnly();
190        mark = -1;
191      int pos = position();      int pos = position();
192      if (pos > 0)      if (pos > 0)
193        {        {
# Line 194  abstract class DirectByteBufferImpl exte Line 196  abstract class DirectByteBufferImpl exte
196          position(count);          position(count);
197          limit(capacity());          limit(capacity());
198        }        }
199        else
200          {
201            position(limit());
202            limit(capacity());
203          }
204      return this;      return this;
205    }    }
206    

Legend:
Removed from v.1.11.2.1  
changed lines
  Added in v.1.11.2.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26