Skip to content
Permalink
Browse files
Add WritableMemory.allocate(cap, order)
  • Loading branch information
leventov committed Nov 6, 2018
1 parent 8034c6c commit 5c643d2c28b6b9c69ce34c3db8cc13846c90de35
Showing 1 changed file with 15 additions and 3 deletions.
@@ -218,9 +218,9 @@ public abstract WritableMemory writableRegion(long offsetBytes, long capacityByt

//ALLOCATE HEAP VIA AUTOMATIC BYTE ARRAY
/**
* Creates on-heap WritableMemory with the given capacity. If the given capacityBytes is zero,
* backing storage, byte order and read-only status of the returned WritableMemory object are
* unspecified.
* Creates on-heap WritableMemory with the given capacity and the native byte order. If the given
* capacityBytes is zero, backing storage, byte order and read-only status of the returned
* WritableMemory object are unspecified.
* @param capacityBytes the given capacity in bytes.
* @return a new WritableMemory for write operations on a new byte array.
*/
@@ -229,6 +229,18 @@ public static WritableMemory allocate(final int capacityBytes) {
return wrap(arr, nativeOrder);
}

/**
* Creates on-heap WritableMemory with the given capacity and byte order. If the given
* capacityBytes is zero, backing storage, byte order and read-only status of the returned
* WritableMemory object are unspecified.
* @param capacityBytes the given capacity in bytes.
* @return a new WritableMemory for write operations on a new byte array.
*/
public static WritableMemory allocate(final int capacityBytes, final ByteOrder byteOrder) {
final byte[] arr = new byte[capacityBytes];
return wrap(arr, byteOrder);
}

//ACCESS PRIMITIVE HEAP ARRAYS for write
/**
* Wraps the given primitive array for write operations assuming native byte order. If the array

0 comments on commit 5c643d2

Please sign in to comment.