Remove VLAs for Compiler Compatibility?

Asked by Brock

Currently, it isn't possible to compile this library with compilers that do not support VLAs. I'm wondering if it would be desirable to replace them with calls to alloca() or malloc() to allow for compatibility with more compilers. If so, I would be happy to submit a pull request containing those changes.

Question information

Language:
English Edit question
Status:
Answered
For:
libvterm Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Launchpad Janitor (janitor) said :
#1

This question was expired because it remained in the 'Open' state without activity for the last 15 days.

Revision history for this message
Paul "LeoNerd" Evans (leonerd) said :
#2

alloca() isn't really much better than the VLAs, to be honest. Also, VLAs were part of C99, a standard which is now almost 20 years old, so really any decent compiler ought to support them by now.

A better plan is a reshaping of the way the parsing works so that dynamic-sized pieces aren't required. That was originally the plan for malloc-less operation during runtime (apart from resize operations), but the current implementation of bits of Unicode combining mean they're still there. It should be possible to take them out though.

Revision history for this message
Paul "LeoNerd" Evans (leonerd) said :
#3

answered

Revision history for this message
Nathan Grenville-Hunt (ngrenvillehunt) said (last edit ):
#4

Hi all,

I actually just submitted a patch for this since VLAs are a material blocker for using the library under Windows/MSVC. I realise now that doing dynamic memory allocation in the proposed way is in contradiction with the stated design goal of zero mallocs (apart from resize), but I'm not in a position to tackle a deeper change.

Please let me know if I can do anything to help move this discussion forward.
Best,
Nathan

Can you help with this problem?

Provide an answer of your own, or ask Brock for more information if necessary.

To post a message you must log in.