Package ghidra.program.model.pcode
Class LinkedByteBuffer
java.lang.Object
ghidra.program.model.pcode.LinkedByteBuffer
A byte buffer that is stored as a linked list of pages. Each page holds BUFFER_SIZE bytes.
A Position object acts as an iterator over the whole buffer. The buffer can be populated
from a stream, either all at once or "as needed" when a Position object iterates past
the current cached set of bytes.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
A linked-list page nodestatic class
An iterator into the byte buffer -
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close the "as needed" stream, if configure.void
getStartPosition
(LinkedByteBuffer.Position position) void
ingestBytes
(byte[] byteArray, int off, int sz) Ingest bytes directly from a byte array.void
ingestStream
(InputStream stream) Read the stream until the end of stream is encountered or until maxCount bytes is reached.void
ingestStreamAsNeeded
(InputStream stream, LinkedByteBuffer.Position start) Set up this buffer so that it reads in pages as needed.void
Ingest stream up to the first 0 byte or until maxCount bytes is reached.void
pad()
Add the padValue to the end of the buffer
-
Field Details
-
BUFFER_SIZE
public static final int BUFFER_SIZE- See Also:
-
-
Constructor Details
-
LinkedByteBuffer
-
-
Method Details
-
close
Close the "as needed" stream, if configure.- Throws:
IOException
- for problems closing the stream
-
ingestStreamAsNeeded
public void ingestStreamAsNeeded(InputStream stream, LinkedByteBuffer.Position start) throws IOException Set up this buffer so that it reads in pages as needed. The initial page is read immediately. Additional pages are read via readNextPage() through the Position methods.- Parameters:
stream
- is the stream to read fromstart
- will hold the initial buffer- Throws:
IOException
- for problems reading data from the stream
-
ingestStreamToNextTerminator
Ingest stream up to the first 0 byte or until maxCount bytes is reached. Store the bytes on the heap in BUFFER_SIZE chunks.- Parameters:
stream
- is the input- Throws:
IOException
- for errors reading from the stream
-
ingestStream
Read the stream until the end of stream is encountered or until maxCount bytes is reached. Store the bytes on the heap in BUFFER_SIZE chunks.- Parameters:
stream
- is the input- Throws:
IOException
- for errors reading from the stream
-
ingestBytes
Ingest bytes directly from a byte array. If these bytes would cause the total number of bytes ingested to exceed the maximum (maxCount) bytes set for this buffer, an exception is thrown. This can be called multiple times to read in different chunks.- Parameters:
byteArray
- is the array of bytesoff
- is the index of the first byte to ingestsz
- is the number of bytes to ingest- Throws:
IOException
- if the max number of bytes to ingest is exceeded
-
pad
public void pad()Add the padValue to the end of the buffer -
getStartPosition
-