diff options
Diffstat (limited to 'java/src/IceInternal/Buffer.java')
-rw-r--r-- | java/src/IceInternal/Buffer.java | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/java/src/IceInternal/Buffer.java b/java/src/IceInternal/Buffer.java new file mode 100644 index 00000000000..de08e52f393 --- /dev/null +++ b/java/src/IceInternal/Buffer.java @@ -0,0 +1,51 @@ +// ********************************************************************** +// +// Copyright (c) 2001 +// MutableRealms, Inc. +// Huntsville, AL, USA +// +// All Rights Reserved +// +// ********************************************************************** + +package IceInternal; + +public class Buffer +{ + public + Buffer() + { + data = new byte[1500]; + pos = 0; + len = 0; + } + + public void + resize(int n) + { + if (n > data.length) + { + int sz = data.length << 1; + byte[] arr = new byte[n < sz ? sz : n]; + System.arraycopy(data, 0, arr, 0, len); + data = arr; + } + len = n; + } + + public void + reserve(int n) + { + if (n > data.length) + { + int sz = data.length << 1; + byte[] arr = new byte[n < sz ? sz : n]; + System.arraycopy(data, 0, arr, 0, len); + data = arr; + } + } + + public byte[] data; + public int pos; + public int len; +} |