31 package com.google.protobuf;
33 import java.nio.ByteBuffer;
40 abstract class BufferAllocator {
41 private static final BufferAllocator UNPOOLED =
42 new BufferAllocator() {
44 public AllocatedBuffer allocateHeapBuffer(
int capacity) {
45 return AllocatedBuffer.wrap(
new byte[capacity]);
49 public AllocatedBuffer allocateDirectBuffer(
int capacity) {
50 return AllocatedBuffer.wrap(ByteBuffer.allocateDirect(capacity));
55 public static BufferAllocator unpooled() {
60 public abstract AllocatedBuffer allocateHeapBuffer(
int capacity);
63 public abstract AllocatedBuffer allocateDirectBuffer(
int capacity);