util/stream: Update OSTREAM_DEF and ISTREAM_DEF #3282
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
OSTREAM_DEF macro is utility macro for creating function table for output stream with function names derived from stream type name.
i.e. OSTREAM_DEF(mem) would create function table like this: const struct out_stream_vft mem_vft = {
.write = mem_write,
.flush = mem_flush,
.pump_from = mem_pump_from,
}
along with prototypes:
static int mem_write(struct out_stream *, const uint8_t *, uint32_t); static int mem_flush(struct out_stream *);
static int mem_pump_from(struct out_stream *, struct in_stream *, uint32_t);
last function was late addition and is optional
This change removes requirement to define pump_from function from OSTREAM_DEF User still can create function table with pump_from funtion without using macro if pumping is required.