diff --git a/buffer/src/main/java/io/netty/buffer/b2/Allocator.java b/buffer/src/main/java/io/netty/buffer/b2/Allocator.java index 8923c85..beb2d15 100644 --- a/buffer/src/main/java/io/netty/buffer/b2/Allocator.java +++ b/buffer/src/main/java/io/netty/buffer/b2/Allocator.java @@ -43,7 +43,7 @@ public interface Allocator extends AutoCloseable { * @param size The size of {@link Buf} to allocate. * @return The newly allocated {@link Buf}. */ - Buf allocate(long size); + Buf allocate(int size); /** * Allocate a {@link Buf} of the given size in bytes. This method may throw an {@link OutOfMemoryError} if there is @@ -55,7 +55,7 @@ public interface Allocator extends AutoCloseable { * @param order The default byte order used by the accessor methods that don't have an explicit byte order. * @return The newly allocated {@link Buf}. */ - default Buf allocate(long size, ByteOrder order) { + default Buf allocate(int size, ByteOrder order) { return allocate(size).order(order); } @@ -71,7 +71,7 @@ public interface Allocator extends AutoCloseable { var man = MemoryManager.getHeapMemoryManager(); return new Allocator() { @Override - public Buf allocate(long size) { + public Buf allocate(int size) { checkSize(size); return man.allocateConfined(size, man.drop(), null); } @@ -82,7 +82,7 @@ public interface Allocator extends AutoCloseable { var man = MemoryManager.getNativeMemoryManager(); return new Allocator() { @Override - public Buf allocate(long size) { + public Buf allocate(int size) { checkSize(size); return man.allocateConfined(size, man.drop(), null); } @@ -93,7 +93,7 @@ public interface Allocator extends AutoCloseable { var man = MemoryManager.getNativeMemoryManager(); return new Allocator() { @Override - public Buf allocate(long size) { + public Buf allocate(int size) { checkSize(size); return man.allocateConfined(size, man.drop(), Statics.CLEANER); } diff --git a/buffer/src/main/java/io/netty/buffer/b2/SizeClassedMemoryPool.java b/buffer/src/main/java/io/netty/buffer/b2/SizeClassedMemoryPool.java index a932424..a095e07 100644 --- a/buffer/src/main/java/io/netty/buffer/b2/SizeClassedMemoryPool.java +++ b/buffer/src/main/java/io/netty/buffer/b2/SizeClassedMemoryPool.java @@ -36,7 +36,7 @@ class SizeClassedMemoryPool implements Allocator, Drop { } @Override - public Buf allocate(long size) { + public Buf allocate(int size) { Allocator.checkSize(size); var sizeClassPool = getSizeClassPool(size); Send send = sizeClassPool.poll(); diff --git a/buffer/src/test/java/io/netty/buffer/b2/CompositeBufTest.java b/buffer/src/test/java/io/netty/buffer/b2/CompositeBufTest.java index bd3dcf7..d27f34d 100644 --- a/buffer/src/test/java/io/netty/buffer/b2/CompositeBufTest.java +++ b/buffer/src/test/java/io/netty/buffer/b2/CompositeBufTest.java @@ -47,8 +47,8 @@ public class CompositeBufTest extends BufTest { var b = secondAllocator.get(); return new Allocator() { @Override - public Buf allocate(long size) { - long half = size / 2; + public Buf allocate(int size) { + int half = size / 2; try (Buf firstHalf = a.allocate(half); Buf secondHalf = b.allocate(size - half)) { return Buf.compose(firstHalf, secondHalf); diff --git a/buffer/src/test/java/io/netty/buffer/b2/DirectBufWithCleanerTest.java b/buffer/src/test/java/io/netty/buffer/b2/DirectBufWithCleanerTest.java index 49ced56..9c5e7ad 100644 --- a/buffer/src/test/java/io/netty/buffer/b2/DirectBufWithCleanerTest.java +++ b/buffer/src/test/java/io/netty/buffer/b2/DirectBufWithCleanerTest.java @@ -44,7 +44,7 @@ public class DirectBufWithCleanerTest extends DirectBufTest { assertThat(sum, lessThan(totalAllocated)); } - protected void allocateAndForget(Allocator allocator, long size) { + protected void allocateAndForget(Allocator allocator, int size) { allocator.allocate(size); } }