Skip to content

Commit da0a4a8

Browse files
Add heapBuffer allocation to BufferAllocator (#1457)
* Add heapBuffer allocation to BufferAllocator * Correct whitespace
1 parent f0aec91 commit da0a4a8

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

common/src/main/java/org/conscrypt/BufferAllocator.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ public abstract class BufferAllocator {
2828
public AllocatedBuffer allocateDirectBuffer(int capacity) {
2929
return AllocatedBuffer.wrap(ByteBuffer.allocateDirect(capacity));
3030
}
31+
32+
@Override
33+
public AllocatedBuffer allocateHeapBuffer(int capacity) {
34+
return AllocatedBuffer.wrap(ByteBuffer.allocate(capacity));
35+
}
3136
};
3237

3338
/**
@@ -41,4 +46,9 @@ public static BufferAllocator unpooled() {
4146
* Allocates a direct (i.e. non-heap) buffer with the given capacity.
4247
*/
4348
public abstract AllocatedBuffer allocateDirectBuffer(int capacity);
49+
50+
/**
51+
* Allocates a heap buffer with the given capacity.
52+
*/
53+
public abstract AllocatedBuffer allocateHeapBuffer(int capacity);
4454
}

0 commit comments

Comments
 (0)