Commit bc32ffea authored by Christopher Dykes's avatar Christopher Dykes Committed by Facebook Github Bot

Eliminate more VLAs

Summary:
MSVC doesn't support them, so use dynamic allocation instead.
This also fixes a place where MSVC wasn't propogating the constexpr-ness of a local into the body of a lambda, resulting in an attempt to create a VLA.

Reviewed By: yfeldblum

Differential Revision: D4098932

fbshipit-source-id: 742b2fcd96f7f6eceb5043159403d557f7fc9673
parent b106dcc7
...@@ -2057,7 +2057,7 @@ TEST(FiberManager, recordStack) { ...@@ -2057,7 +2057,7 @@ TEST(FiberManager, recordStack) {
auto& loopController = auto& loopController =
dynamic_cast<SimpleLoopController&>(fm.loopController()); dynamic_cast<SimpleLoopController&>(fm.loopController());
constexpr size_t n = 1000; static constexpr size_t n = 1000;
int s = 0; int s = 0;
fm.addTask([&]() { fm.addTask([&]() {
int b[n] = {0}; int b[n] = {0};
......
...@@ -1103,11 +1103,12 @@ char* copyWithSameAlignment(char* dst, const char* src, size_t length) { ...@@ -1103,11 +1103,12 @@ char* copyWithSameAlignment(char* dst, const char* src, size_t length) {
void testToLowerAscii(Range<const char*> src) { void testToLowerAscii(Range<const char*> src) {
// Allocate extra space so we can make copies that start at the // Allocate extra space so we can make copies that start at the
// same alignment (byte, word, quadword, etc) as the source buffer. // same alignment (byte, word, quadword, etc) as the source buffer.
char controlBuf[src.size() + 7]; auto controlBuf = std::vector<char>(src.size() + 7);
char* control = copyWithSameAlignment(controlBuf, src.begin(), src.size()); char* control =
copyWithSameAlignment(controlBuf.data(), src.begin(), src.size());
char testBuf[src.size() + 7]; auto testBuf = std::vector<char>(src.size() + 7);
char* test = copyWithSameAlignment(testBuf, src.begin(), src.size()); char* test = copyWithSameAlignment(testBuf.data(), src.begin(), src.size());
for (size_t i = 0; i < src.size(); i++) { for (size_t i = 0; i < src.size(); i++) {
control[i] = tolower(control[i]); control[i] = tolower(control[i]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment