From 4628f3f2a03e23b08d07d69039de9485172bc4ce Mon Sep 17 00:00:00 2001 From: Brendan Le Foll Date: Mon, 1 Jun 2015 09:32:44 +0100 Subject: [PATCH] uart.hpp: Use std::string constructor which lets use set a size parameter Signed-off-by: Brendan Le Foll --- api/mraa/uart.hpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/api/mraa/uart.hpp b/api/mraa/uart.hpp index 5a92fb3..f1d6ffb 100644 --- a/api/mraa/uart.hpp +++ b/api/mraa/uart.hpp @@ -104,11 +104,8 @@ class Uart { char* data = (char*) malloc(sizeof(char) * length); int v = mraa_uart_read(m_uart, data, (size_t) length); - char* out = (char*) malloc(sizeof(char) * v); - strncpy(out, data, v); - std::string ret(out); + std::string ret(data, v); free(data); - free(out); return ret; }