From 38e2d09a422b912bbecbbc04c116670ed4779af8 Mon Sep 17 00:00:00 2001 From: eidheim Date: Fri, 11 Mar 2016 11:22:03 +0100 Subject: [PATCH] Replaced unsafe std::vector and its reserve with std::array in the default_resource examples --- http_examples.cpp | 6 +++--- https_examples.cpp | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/http_examples.cpp b/http_examples.cpp index 24e72e7..b00cd64 100644 --- a/http_examples.cpp +++ b/http_examples.cpp @@ -9,6 +9,7 @@ //Added for the default_resource example #include #include +#include using namespace std; //Added for the json-example: @@ -105,9 +106,8 @@ int main() { response << "HTTP/1.1 200 OK\r\nContent-Length: " << length << "\r\n\r\n"; //read and send 128 KB at a time - size_t buffer_size=131072; - vector buffer; - buffer.reserve(buffer_size); + const size_t buffer_size=131072; + array buffer; size_t read_length; try { while((read_length=ifs.read(&buffer[0], buffer_size).gcount())>0) { diff --git a/https_examples.cpp b/https_examples.cpp index 54e62ab..d9c2096 100644 --- a/https_examples.cpp +++ b/https_examples.cpp @@ -9,6 +9,7 @@ //Added for the default_resource example #include #include +#include using namespace std; //Added for the json-example: @@ -105,9 +106,8 @@ int main() { response << "HTTP/1.1 200 OK\r\nContent-Length: " << length << "\r\n\r\n"; //read and send 128 KB at a time - size_t buffer_size=131072; - vector buffer; - buffer.reserve(buffer_size); + const size_t buffer_size=131072; + array buffer; size_t read_length; try { while((read_length=ifs.read(&buffer[0], buffer_size).gcount())>0) {