Reserve memory of the given capacity in the current buffer
(long capacity)
| 193 | |
| 194 | // Reserve memory of the given capacity in the current buffer |
| 195 | public void Reserve(long capacity) |
| 196 | { |
| 197 | Debug.Assert((capacity >= 0), "Invalid reserve capacity!"); |
| 198 | if (capacity < 0) |
| 199 | throw new ArgumentException("Invalid reserve capacity!", nameof(capacity)); |
| 200 | |
| 201 | if (capacity > Capacity) |
| 202 | { |
| 203 | byte[] data = new byte[Math.Max(capacity, 2 * Capacity)]; |
| 204 | Array.Copy(_data, 0, data, 0, _size); |
| 205 | _data = data; |
| 206 | } |
| 207 | } |
| 208 | |
| 209 | // Resize the current buffer |
| 210 | public void Resize(long size) |