return unique ptr instead of raw ptr

This commit is contained in:
Dennis Luxen 2014-07-28 11:03:53 +02:00
parent cc7c6b9ece
commit 797243fc9c

View File

@ -30,19 +30,22 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "Server.h"
#include "../Util/SimpleLogger.h"
#include "../Util/SmartPointerUtil.h"
#include <zlib.h>
#include <memory>
struct ServerFactory
{
ServerFactory() = delete;
ServerFactory(const ServerFactory &) = delete;
static Server *CreateServer(std::string &ip_address, int ip_port, unsigned requested_num_threads)
static std::unique_ptr<Server> CreateServer(std::string &ip_address, int ip_port, unsigned requested_num_threads)
{
SimpleLogger().Write() << "http 1.1 compression handled by zlib version " << zlibVersion();
const unsigned hardware_threads = std::max(1u, std::thread::hardware_concurrency());
const unsigned real_num_threads = std::min(hardware_threads, requested_num_threads);
return new Server(ip_address, ip_port, real_num_threads);
return osrm::make_unique<Server>(ip_address, ip_port, real_num_threads);
}
};