*/
CProcess::CProcess(const wstring& CommandLine, LPSTARTUPINFOW StartupInfo)
{
- auto_array_ptr<WCHAR> CommandLinePtr(new WCHAR[CommandLine.size() + 1]);
+ unique_ptr<WCHAR[]> CommandLinePtr(new WCHAR[CommandLine.size() + 1]);
- wcscpy(CommandLinePtr, CommandLine.c_str());
+ wcscpy(CommandLinePtr.get(), CommandLine.c_str());
- if(!CreateProcessW(NULL, CommandLinePtr, NULL, NULL, TRUE, NORMAL_PRIORITY_CLASS, NULL, NULL, StartupInfo, &m_ProcessInfo))
+ if(!CreateProcessW(NULL, CommandLinePtr.get(), NULL, NULL, TRUE, NORMAL_PRIORITY_CLASS, NULL, NULL, StartupInfo, &m_ProcessInfo))
TESTEXCEPTION("CreateProcessW failed\n");
}
{
const WCHAR szHeaders[] = L"Content-Type: application/x-www-form-urlencoded";
- auto_array_ptr<char> Data;
+ unique_ptr<char[]> Data;
DWORD DataLength;
/* Post our test results to the web service */
FATAL("HttpOpenRequestW failed\n");
Data.reset(new char[InputData.size() + 1]);
- strcpy(Data, InputData.c_str());
+ strcpy(Data.get(), InputData.c_str());
- if(!HttpSendRequestW(m_hHTTPRequest, szHeaders, lstrlenW(szHeaders), Data, (DWORD)InputData.size()))
+ if(!HttpSendRequestW(m_hHTTPRequest, szHeaders, lstrlenW(szHeaders), Data.get(), (DWORD)InputData.size()))
FATAL("HttpSendRequestW failed\n");
/* Get the response */
Data.reset(new char[DataLength + 1]);
- if(!InternetReadFile(m_hHTTPRequest, Data, DataLength, &DataLength))
+ if(!InternetReadFile(m_hHTTPRequest, Data.get(), DataLength, &DataLength))
FATAL("InternetReadFile failed\n");
Data[DataLength] = 0;
void
CWebService::Finish(const char* TestType)
{
- auto_array_ptr<char> Response;
+ unique_ptr<char[]> Response;
string Data;
stringstream ss;
Response.reset(DoRequest(Data));
- if (strcmp(Response, "OK"))
+ if (strcmp(Response.get(), "OK"))
{
- ss << "When finishing the test run, the server responded:" << endl << Response << endl;
+ ss << "When finishing the test run, the server responded:" << endl << Response.get() << endl;
SSEXCEPTION;
}
}
PCHAR
CWebService::GetSuiteID(const char* TestType, CTestInfo* TestInfo)
{
- auto_array_ptr<char> SuiteID;
+ unique_ptr<char[]> SuiteID;
string Data;
Data = "action=getsuiteid";
SuiteID.reset(DoRequest(Data));
/* Verify that this is really a number */
- if(!IsNumber(SuiteID))
+ if(!IsNumber(SuiteID.get()))
{
stringstream ss;
- ss << "Expected Suite ID, but received:" << endl << SuiteID << endl;
+ ss << "Expected Suite ID, but received:" << endl << SuiteID.get() << endl;
SSEXCEPTION;
}
void
CWebService::Submit(const char* TestType, CTestInfo* TestInfo)
{
- auto_array_ptr<char> Response;
- auto_array_ptr<char> SuiteID;
+ unique_ptr<char[]> Response;
+ unique_ptr<char[]> SuiteID;
string Data;
stringstream ss;
Data += "&testid=";
Data += m_TestID;
Data += "&suiteid=";
- Data += SuiteID;
+ Data += SuiteID.get();
Data += "&log=";
Data += EscapeString(TestInfo->Log);
Response.reset(DoRequest(Data));
- if (strcmp(Response, "OK"))
+ if (strcmp(Response.get(), "OK"))
{
- ss << "When submitting the result, the server responded:" << endl << Response << endl;
+ ss << "When submitting the result, the server responded:" << endl << Response.get() << endl;
SSEXCEPTION;
}
}
+++ /dev/null
-/*
- * PROJECT: ReactOS Automatic Testing Utility
- * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
- * PURPOSE: Template similar to std::auto_ptr for arrays
- * COPYRIGHT: Copyright 2009 Colin Finck (colin@reactos.org)
- */
-
-template<typename Type>
-class auto_array_ptr
-{
-private:
- Type* m_Ptr;
-
-public:
- typedef Type element_type;
-
- /* Construct an auto_array_ptr from a pointer */
- explicit auto_array_ptr(Type* Ptr = 0) throw()
- : m_Ptr(Ptr)
- {
- }
-
- /* Construct an auto_array_ptr from an existing auto_array_ptr */
- auto_array_ptr(auto_array_ptr<Type>& Right) throw()
- : m_Ptr(Right.release())
- {
- }
-
- /* Destruct the auto_array_ptr and remove the corresponding array from memory */
- ~auto_array_ptr() throw()
- {
- delete[] m_Ptr;
- }
-
- /* Get the pointer address */
- Type* get() const throw()
- {
- return m_Ptr;
- }
-
- /* Release the pointer */
- Type* release() throw()
- {
- Type* Tmp = m_Ptr;
- m_Ptr = 0;
-
- return Tmp;
- }
-
- /* Reset to a new pointer */
- void reset(Type* Ptr = 0) throw()
- {
- if(Ptr != m_Ptr)
- delete[] m_Ptr;
-
- m_Ptr = Ptr;
- }
-
- /* Simulate all the functionality of real arrays by casting the auto_array_ptr to Type* on demand */
- operator Type*() const throw()
- {
- return m_Ptr;
- }
-};