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

BUG: Use C99 flexible arrays instead of type[1] trailing member #77

Closed
Flamefire opened this issue Jul 27, 2019 · 0 comments · Fixed by #79 or #81
Closed

BUG: Use C99 flexible arrays instead of type[1] trailing member #77

Flamefire opened this issue Jul 27, 2019 · 0 comments · Fixed by #79 or #81

Comments

@Flamefire
Copy link
Contributor

Related to #68 as it requires C99 (although C99 features are already used)

C99 flexible arrays are used at some points, e.g.: https://github.com/erikd/libsamplerate/blob/2647fd9bac5f11f24b5f1ee55806671f81520f66/src/src_sinc.c#L57

At other the idiom of having a trailing float[1] member is used: https://github.com/erikd/libsamplerate/blob/2647fd9bac5f11f24b5f1ee55806671f81520f66/src/src_linear.c#L34

A SO answer highly recommends using the C99 feature: https://stackoverflow.com/a/247040/1930508 with a comment that using float[1] may produce incorrect code: https://lkml.org/lkml/2015/2/18/407

Furthermore to much memory is allocated (1 additional float): https://github.com/erikd/libsamplerate/blob/2647fd9bac5f11f24b5f1ee55806671f81520f66/src/src_linear.c#L174

Bottom line:

  • Require C99 compiler
  • Use flexible arrays instead of trailing float[1]
Flamefire added a commit to Flamefire/libsamplerate that referenced this issue Jul 29, 2019
Flamefire added a commit to Flamefire/libsamplerate that referenced this issue Jul 29, 2019
Already required for configure builds, now also for CMake builds.
Simplifies some code as e.g. lrint and stdint.h are always available.
Closes libsndfile#77
Flamefire added a commit to Flamefire/libsamplerate that referenced this issue Jul 29, 2019
Already required for configure builds, now also for CMake builds.
Simplifies some code as e.g. lrint and stdint.h are always available.
Closes libsndfile#77
@erikd erikd closed this as completed in #79 Jul 29, 2019
erikd pushed a commit that referenced this issue Jul 29, 2019
Flamefire added a commit to Flamefire/libsamplerate that referenced this issue Aug 9, 2019
Already required for configure builds, now also for CMake builds.
Simplifies some code as e.g. lrint and stdint.h are always available.
Closes libsndfile#77
erikd pushed a commit that referenced this issue Aug 10, 2019
Already required for configure builds, now also for CMake builds.
Simplifies some code as e.g. lrint and stdint.h are always available.
Closes #77
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant