|
|
|
@ -21,25 +21,39 @@ typedef uint8_t byte_t;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
llarp_buffer_t represents a region of memory that is ONLY
|
|
|
|
|
accessable and valid in the current scope.
|
|
|
|
|
valid in the current scope.
|
|
|
|
|
|
|
|
|
|
rules:
|
|
|
|
|
make sure to follow the rules:
|
|
|
|
|
|
|
|
|
|
ALWAYS copy the contents of the buffer
|
|
|
|
|
if that data is to be used outside the current scope.
|
|
|
|
|
ALWAYS copy the contents of the buffer if that data is to be used outside the
|
|
|
|
|
current scope.
|
|
|
|
|
|
|
|
|
|
ALWAYS pass a llarp_buffer_t * if you plan on modifying
|
|
|
|
|
the data associated with the buffer
|
|
|
|
|
ALWAYS pass a llarp_buffer_t * if you plan on modifying the data associated
|
|
|
|
|
with the buffer
|
|
|
|
|
|
|
|
|
|
ALWAYS pass a llarp_buffer_t * if you plan on advancing
|
|
|
|
|
the stream position
|
|
|
|
|
ALWAYS pass a llarp_buffer_t * if you plan on advancing the stream position
|
|
|
|
|
|
|
|
|
|
ALWAYS pass a llarp_buffer_t if you are doing a read
|
|
|
|
|
only operation that does not modify anything
|
|
|
|
|
ALWAYS pass a llarp_buffer_t if you are doing a read only operation that does
|
|
|
|
|
not modify the buffer
|
|
|
|
|
|
|
|
|
|
NEVER dallocate the pointers in the buffer
|
|
|
|
|
ALWAYS pass a llarp_buffer_t if you don't want to advance the stream position
|
|
|
|
|
|
|
|
|
|
NEVER use llarp_buffer_t ** (double pointer)
|
|
|
|
|
ALWAYS bail out of the current operation if you run out of space in a buffer
|
|
|
|
|
|
|
|
|
|
ALWAYS assume the pointers in the buffer are stack allocated memory
|
|
|
|
|
(yes even if you know they are not)
|
|
|
|
|
|
|
|
|
|
NEVER malloc() the pointers in the buffer when using it
|
|
|
|
|
|
|
|
|
|
NEVER realloc() the pointers in the buffer when using it
|
|
|
|
|
|
|
|
|
|
NEVER free() the pointers in the buffer when using it
|
|
|
|
|
|
|
|
|
|
NEVER use llarp_buffer_t ** (double pointers)
|
|
|
|
|
|
|
|
|
|
NEVER use llarp_buffer_t ** (double pointers)
|
|
|
|
|
|
|
|
|
|
ABSOLUTELY NEVER USE DOUBLE POINTERS.
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
typedef struct llarp_buffer_t
|
|
|
|
|