diff --git a/networktables/cpp/lib/share/networktables2/connection/DataIOStream.cpp b/networktables/cpp/lib/share/networktables2/connection/DataIOStream.cpp index f9e1b63267..e03e3515e4 100644 --- a/networktables/cpp/lib/share/networktables2/connection/DataIOStream.cpp +++ b/networktables/cpp/lib/share/networktables2/connection/DataIOStream.cpp @@ -1,9 +1,5 @@ #include "networktables2/connection/DataIOStream.h" - -//TODO remove this when alloca is solved -#ifdef WIN32 -#include -#endif +#include ///This is used in case NULL is passed so all logic calls to IOstream can continue to assume there is never a null pointer class InertStream : public IOStream @@ -73,14 +69,8 @@ uint16_t DataIOStream::read2BytesBE() } std::string* DataIOStream::readString() { - unsigned int byteLength = read2BytesBE(); -#ifndef WIN32 - uint8_t bytes[byteLength+1];//FIXME figure out why this doesn't work on windows -#else - uint8_t* bytes = (uint8_t*)alloca(byteLength+1); -#endif - iostream->read(bytes, byteLength); - bytes[byteLength] = 0; - return new std::string((char*)bytes);//FIXME implement UTF-8 aware version + auto bytes = std::make_unique(byteLength); + iostream->read(bytes.get(), byteLength); + return new std::string(bytes.get());//FIXME implement UTF-8 aware version } diff --git a/wpilibc/wpilibC++Devices/src/USBCamera.cpp b/wpilibc/wpilibC++Devices/src/USBCamera.cpp index 74870ad50d..eb61eca9b4 100644 --- a/wpilibc/wpilibC++Devices/src/USBCamera.cpp +++ b/wpilibc/wpilibC++Devices/src/USBCamera.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include @@ -130,8 +131,8 @@ void USBCamera::UpdateSettings() { uInt32 count = 0; uInt32 currentMode = 0; SAFE_IMAQ_CALL(IMAQdxEnumerateVideoModes, m_id, nullptr, &count, ¤tMode); - IMAQdxVideoMode modes[count]; - SAFE_IMAQ_CALL(IMAQdxEnumerateVideoModes, m_id, modes, &count, ¤tMode); + auto modes = std::make_unique(count); + SAFE_IMAQ_CALL(IMAQdxEnumerateVideoModes, m_id, modes.get(), &count, ¤tMode); // Groups are: // 0 - width diff --git a/wpilibc/wpilibC++Devices/src/Vision/BaeUtilities.cpp b/wpilibc/wpilibC++Devices/src/Vision/BaeUtilities.cpp index 5059e1e5cc..e1c28946c9 100644 --- a/wpilibc/wpilibC++Devices/src/Vision/BaeUtilities.cpp +++ b/wpilibc/wpilibC++Devices/src/Vision/BaeUtilities.cpp @@ -290,7 +290,7 @@ be one property=value entry on each line, i.e. "exposure=auto" **/ int processFile(char *inputFile, char *outputString, int lineNumber) { FILE *infile; - int stringSize = 80; // max size of one line in file + const int stringSize = 80; // max size of one line in file char inputStr[stringSize]; int lineCount = 0;