aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/com/sun/gluegen/runtime/BufferFactory.java.javase
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2010-01-19 00:06:39 +0100
committerMichael Bien <[email protected]>2010-01-19 00:06:39 +0100
commit6bc9851ab091f5135f489b928cd42a27045fb5ed (patch)
tree8f367ecbcbce36c524028a7240b35707661acbe1 /src/java/com/sun/gluegen/runtime/BufferFactory.java.javase
parentd17e416ba518b3095e863197509c37f0708f1934 (diff)
PointerBuffer supports now 32bit architectures.
Diffstat (limited to 'src/java/com/sun/gluegen/runtime/BufferFactory.java.javase')
-rwxr-xr-xsrc/java/com/sun/gluegen/runtime/BufferFactory.java.javase9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/java/com/sun/gluegen/runtime/BufferFactory.java.javase b/src/java/com/sun/gluegen/runtime/BufferFactory.java.javase
index cb8c770..60a79c3 100755
--- a/src/java/com/sun/gluegen/runtime/BufferFactory.java.javase
+++ b/src/java/com/sun/gluegen/runtime/BufferFactory.java.javase
@@ -130,7 +130,8 @@ public class BufferFactory {
return pos * SIZEOF_CHAR;
}
} else if (buf instanceof PointerBuffer) {
- return (((PointerBuffer)buf).position() * SIZEOF_LONG);
+ PointerBuffer pb = (PointerBuffer)buf;
+ return pb.position() * pb.elementSize();
}
throw new RuntimeException("Disallowed array backing store type in buffer "
@@ -195,7 +196,8 @@ public class BufferFactory {
return (SIZEOF_CHAR*(((CharBuffer)buf).arrayOffset() + pos));
}
} else if(buf instanceof PointerBuffer) {
- return (SIZEOF_LONG*(((PointerBuffer)buf).arrayOffset() + ((PointerBuffer)buf).position()));
+ PointerBuffer pb = (PointerBuffer)buf;
+ return pb.elementSize()*(pb.arrayOffset() + pb.position());
}
throw new RuntimeException("Unknown buffer type " + buf.getClass().getName());
@@ -305,7 +307,8 @@ public class BufferFactory {
bytesRemaining = elementsRemaining * SIZEOF_CHAR;
}
} else if (buffer instanceof PointerBuffer) {
- bytesRemaining = ((PointerBuffer)buffer).remaining() * SIZEOF_LONG;
+ PointerBuffer pb = (PointerBuffer)buffer;
+ bytesRemaining = pb.remaining() * pb.elementSize();
}
if (bytesRemaining < minBytesRemaining) {
throw new IndexOutOfBoundsException("Required " + minBytesRemaining + " remaining bytes in buffer, only had " + bytesRemaining);