47 static size_t _writes(
void *ip,
const uint8_t *bp,
size_t n) {
50 if (msp->size - msp->eos < n)
51 n = msp->size - msp->eos;
52 memcpy(msp->buffer + msp->eos, bp, n);
57 static size_t _reads(
void *ip, uint8_t *bp,
size_t n) {
60 if (msp->eos - msp->offset < n)
61 n = msp->eos - msp->offset;
62 memcpy(bp, msp->buffer + msp->offset, n);
67 static msg_t _put(
void *ip, uint8_t b) {
70 if (msp->size - msp->eos <= 0)
72 *(msp->buffer + msp->eos) = b;
77 static msg_t _get(
void *ip) {
81 if (msp->eos - msp->offset <= 0)
83 b = *(msp->buffer + msp->offset);
88 static const struct MemStreamVMT vmt = {(size_t)0, _writes, _reads, _put, _get};
105 size_t size,
size_t eos) {
108 msp->buffer = buffer;
void msObjectInit(MemoryStream *msp, uint8_t *buffer, size_t size, size_t eos)
Memory stream object initialization.
const struct MemStreamVMT * vmt
Virtual Methods Table.
int32_t msg_t
Type of a message.
Memory streams structures and macros.
MemStream virtual methods table.