ssize_t writeToFD(int fd, size_t length) {
// write an arbitrary amount of data to the fd
- char buf[length];
- memset(buf, 'a', sizeof(buf));
- ssize_t rc = write(fd, buf, sizeof(buf));
+ auto bufv = vector<char>(length);
+ auto buf = bufv.data();
+ memset(buf, 'a', length);
+ ssize_t rc = write(fd, buf, length);
CHECK_EQ(rc, length);
return rc;
}
ssize_t readFromFD(int fd, size_t length) {
// write an arbitrary amount of data to the fd
- char buf[length];
- return read(fd, buf, sizeof(buf));
+ auto buf = vector<char>(length);
+ return read(fd, buf.data(), length);
}
size_t readUntilEmpty(int fd) {
rng = RandomT(localSeed);
f_wfbstring(wc);
int wret = wcslen(wc.c_str());
- char mb[wret+1];
- int ret = wcstombs(mb, wc.c_str(), sizeof(mb));
+ auto mbv = std::vector<char>(wret + 1);
+ auto mb = mbv.data();
+ int ret = wcstombs(mb, wc.c_str(), wret + 1);
if (ret == wret) mb[wret] = '\0';
const char *mc = c.c_str();
std::string one(mb);