rs: repurpose reed_solomon_init() to initialize static buffer #5

Merged
benpicco merged 1 commit from reed_solomon_init into master 2023-03-10 13:58:21 -06:00
benpicco commented 2023-03-10 08:49:28 -06:00 (Migrated from github.com)

nanors only uses the heap in reed_solomon_new() to allocate a context struct.
If we don't want to use the heap at all (only use static allocation) we can also provide that buffer and initialize it with the context.

The most natural name for this would be reed_solomon_init() but this function already exists - turns out it's a no-op.

So instead of coming up with a new function name, I decided to repurposed reed_solomon_init() for this.

nanors only uses the heap in `reed_solomon_new()` to allocate a context struct. If we don't want to use the heap at all (only use static allocation) we can also provide that buffer and initialize it with the context. The most natural name for this would be `reed_solomon_init()` but this function already exists - turns out it's a no-op. So instead of coming up with a new function name, I decided to repurposed `reed_solomon_init()` for this.
sleepybishop commented 2023-03-10 09:56:01 -06:00 (Migrated from github.com)

Thank you for the PR. When I first wrote this, I used the same interface as

https://github.com/moonlight-stream/moonlight-common-c/blob/master/reedsolomon/rs.h

In that implementation, reed_solomon_init() is used to precalculate the lookup tables for finite field multiplication. That is not required in nanors so it became a no-op to maintain compatibility which I'd prefer to retain.

Would you consider something along the lines of reed_solomon_alloc() ?

Thank you for the PR. When I first wrote this, I used the same interface as https://github.com/moonlight-stream/moonlight-common-c/blob/master/reedsolomon/rs.h In that implementation, `reed_solomon_init()` is used to precalculate the lookup tables for finite field multiplication. That is not required in nanors so it became a no-op to maintain compatibility which I'd prefer to retain. Would you consider something along the lines of `reed_solomon_alloc()` ?
benpicco commented 2023-03-10 11:54:24 -06:00 (Migrated from github.com)

Hm but the function does not do any allocating - how about reed_solomon_new_static() or reed_solomon_new_with_buf()?

Hm but the function does not do any allocating - how about `reed_solomon_new_static()` or `reed_solomon_new_with_buf()`?
sleepybishop commented 2023-03-10 12:00:37 -06:00 (Migrated from github.com)

Sure, I don't really have a preference, reed_solomon_prepare() might also work, up to you. My main interest is in retaining compatibility with the existing interface.

Sure, I don't really have a preference, `reed_solomon_prepare()` might also work, up to you. My main interest is in retaining compatibility with the existing interface.
sleepybishop (Migrated from github.com) approved these changes 2023-03-10 13:58:16 -06:00
sleepybishop (Migrated from github.com) left a comment

Thank you!

Thank you!
Sign in to join this conversation.
No description provided.