Is it a good idea to use C99 VLA compared to malloc/free?

后端 未结 6 728
旧时难觅i
旧时难觅i 2020-11-28 11:26

Is it a good idea to use C99 VLA? When is it appropriate to use VLA compared to malloc/free? (since VLA may blow up stack?)

6条回答
  •  遥遥无期
    2020-11-28 11:57

    It is a good idea to use C99 VLAs if you have a project that you're only going to compile with a C99 compliant compiler and the alternative is to use alloca(). VLAs should not be used where you would normally use malloc() and if you don't know what alloca() does and what problems you might run into, you should not be using VLAs.

提交回复
热议问题