Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

util/stream: Update OSTREAM_DEF and ISTREAM_DEF #3282

Merged

Conversation

kasjer
Copy link
Contributor

@kasjer kasjer commented Jul 2, 2024

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.

@kasjer kasjer added Trivial Trivial fix BugFix Bug fix labels Jul 2, 2024
@kasjer kasjer requested a review from rymanluk July 2, 2024 06:21
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 function without
using macro if pumping is required.

Same applies to ISTREAM_DEF
@kasjer kasjer force-pushed the kasjer/ostream-pump_from-null-by-default branch from c7b1470 to 56a9d8c Compare July 2, 2024 06:30
@kasjer kasjer changed the title util/stream: Update OSTREAM_DEF util/stream: Update OSTREAM_DEF and ISTREAM_DEF Jul 2, 2024
@kasjer kasjer merged commit 616d3e6 into apache:master Jul 2, 2024
17 checks passed
@kasjer kasjer deleted the kasjer/ostream-pump_from-null-by-default branch July 2, 2024 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BugFix Bug fix Trivial Trivial fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants