class MemoryManager
extends java.lang.Object
Constructor and Description |
---|
MemoryManager() |
Modifier and Type | Method and Description |
---|---|
(package private) static long |
allocate(long len)
Allocate the given number of bytes as a new memory block and return the 64-bit address.
|
(package private) static int |
compiledWordSize()
Returns the word size (the size of a pointer) for the native code as compiled.
|
(package private) static void |
copy(long source,
long dest,
long offset,
long len)
Copy the specified range of contents from the source memory block to the destination memory
block.
|
(package private) static void |
deallocate(long addr)
De-allocate the memory block at the given 64-bit address.
|
(package private) static long |
findNextNull(long addr,
long idx,
long size)
Returns the next index position into the array which is the
null byte, starting
at the given index position. |
(package private) static boolean |
isLittleEndian()
Reports on the native byte-ordering of the platform on which this library is
running.
|
(package private) static byte[] |
read(long addr,
long offset,
long len)
Read the specified range of contents from the memory block at the given 64-bit address.
|
(package private) static void |
write(long addr,
long offset,
byte[] data)
Write the specified contents to the memory block at the given 64-bit address plus offset.
|
static boolean isLittleEndian()
true
if the platform uses little-endian byte-ordering,
false
if the platform is big-endian.static int compiledWordSize()
static long allocate(long len)
To duplicate the permissiveness of the 4GL memptr allocation (where certain operations often can read or write past the end of the allocated buffer without an access violation), the buffer allocated by this function will always be 16 bytes larger than the requested size.
len
- The size in bytes of the memory region to allocate.static void deallocate(long addr)
addr
- The 64-bit pointer to a memory region previously allocated using this module.
DO NOT pass in an invalid pointer. DO NOT deallocate the same pointer more than
once.static long findNextNull(long addr, long idx, long size)
null
byte, starting
at the given index position.addr
- The 64-bit pointer to a memory region previously allocated using this module.
DO NOT pass in an invalid pointer.idx
- The index position at which to start the search.size
- The length of the buffer. If the search reaches this byte without finding a
null byte, then this value will be returned. If this is given as -1, then the
caller has no size information and we operate in unsafe mode. In this mode
the code will read until it finds a null
or gets an access
violation. This is how the 4GL does it too.null
byte or
the length of the array if no null
byte is contained.static byte[] read(long addr, long offset, long len)
addr
- The 64-bit pointer to a memory region previously allocated using this module.
DO NOT pass in an invalid pointer.offset
- The 0-based index position from the beginning of the buffer, from which to start
reading.len
- The number of bytes to read. Must be greater than 0 and must NOT extend past the
end of the buffer.null
if there is any problem allocating
the array.static void write(long addr, long offset, byte[] data)
addr
- The 64-bit pointer to a memory region previously allocated using this module.
DO NOT pass in an invalid pointer.offset
- The 0-based index position from the beginning of the buffer, at which to start
writing.data
- The bytes to write. The entire contents of the array will be written. The length
of the array must not be bigger than the number of bytes between the offset and
the end of the buffer.static void copy(long source, long dest, long offset, long len)
source
- The 64-bit pointer to a memory region previously allocated using this module.
DO NOT pass in an invalid pointer.dest
- The 64-bit pointer to a memory region previously allocated using this module.
DO NOT pass in an invalid pointer.offset
- The 0-based index position from the beginning of the buffer, at which to start
writing.len
- The number of bytes to write. Must be greater than 0 and must NOT extend past the
end of the destination buffer.