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

Remove VLA #1273

Merged
merged 5 commits into from
Aug 2, 2023
Merged

Remove VLA #1273

merged 5 commits into from
Aug 2, 2023

Conversation

BenBE
Copy link
Member

@BenBE BenBE commented Jul 28, 2023

This removes various instances of VLA in the code.

The two instances in RichString.c (RichString_writeFromWide & RichString_appendnWideColumns) have been kept intentionally, for performance reasons AND the alternatives (like alloca) would be less clear.

Those cases aside, I hope I caught all the other instances of VLA in the code.

@BenBE BenBE added code quality ♻️ Code quality enhancement Linux 🐧 Linux related issues MacOS 🍏 MacOS / Darwin related issues BSD 🐡 Issues related to *BSD labels Jul 28, 2023
@BenBE BenBE added this to the 3.3.0 milestone Jul 28, 2023
char cpuBrandString[cpuBrandStringSize];
Platform_getCPUBrandString(cpuBrandString, cpuBrandStringSize);
char cpuBrandString[1024] = "";
Platform_getCPUBrandString(cpuBrandString, sizeof(cpuBrandString));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically not VLA but this change helps readability anyway :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Um, actually … ;-) Although this uses a constant number (which the compiler can deduce), syntactically it iswas.

BTW: I did a grep --color=always -nRP '\b(?!return)\w+ \w+\[[^\]0-9A-Z_]'|less -R through the source and had a look at the remaining locations found by this. Quite a nice way to quickly get through the source without straight up working with the AST …

Copy link
Member

@natoscott natoscott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Copy link
Member

@fasterit fasterit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, thanks for the housekeeping!

@fasterit fasterit merged commit 278ebbb into htop-dev:main Aug 2, 2023
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BSD 🐡 Issues related to *BSD code quality ♻️ Code quality enhancement Linux 🐧 Linux related issues MacOS 🍏 MacOS / Darwin related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants