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

Add USE_MALLOC define, to toggle the use of malloc() and free() instead of VLA #164

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

davidebeatrici
Copy link

This is required for MSVC.

@petterreinholdtsen
Copy link
Contributor

The USE_MALLOC name is a bit confusing, as the code of course use mallom even if USE_MALLOC is not defined... What about HAVE_VLA_SUPPORT or something like that instead? Is there some flag in modern C that can be used to detect compilers with such advanced feature available without manually setting a flag?

@davidebeatrici
Copy link
Author

According to https://stackoverflow.com/a/49988810 we can use __STDC_NO_VLA__.

@davidebeatrici
Copy link
Author

Should I do that?

@petterreinholdtsen
Copy link
Contributor

petterreinholdtsen commented Mar 11, 2021 via email

@marler8997
Copy link

marler8997 commented Nov 22, 2023

Here's my own take on a fix: #219

Relevant differences:

  • use alloca instead of malloc
  • use C std version and __STDC_NO_VLA__ to automatically determine VLA support
    • application still has the option to manually define NO_VLA if the automatic detection doesn't work with their toolchain
  • define a stackalloc abstraction so we don't need the ifdefs all over the source

@jmvalin
Copy link
Member

jmvalin commented Mar 26, 2024

Can you give the upgrade1 branch a try. The VLAs should all be replaced with fixes sizes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants