diff --git a/src/stockfish.cpp b/src/stockfish.cpp index 00eb675..88a38f0 100644 --- a/src/stockfish.cpp +++ b/src/stockfish.cpp @@ -12,11 +12,8 @@ #include #endif -#define BUFFER_SIZE 1024 - -#include "stockfish.h" - #include "fixes.h" +#include "stockfish.h" const char *QUITOK = "quitok\n"; @@ -54,17 +51,10 @@ ssize_t stockfish_stdin_write(char *data) { } std::string data; -char buffer[BUFFER_SIZE + 1]; -char* stockfish_stdout_read() { +const char *stockfish_stdout_read() { if (getline(fakeout, data)) { - size_t len = data.length(); - size_t i; - for (i = 0; i < len && i < BUFFER_SIZE; i++) { - buffer[i] = data[i]; - } - buffer[i] = 0; - return buffer; + return data.c_str(); } return nullptr; } \ No newline at end of file diff --git a/src/stockfish.h b/src/stockfish.h index c950bcf..b7fa36f 100644 --- a/src/stockfish.h +++ b/src/stockfish.h @@ -45,4 +45,4 @@ FFI_PLUGIN_EXPORT ssize_t stockfish_stdin_write(char *data); #ifndef _ffigen extern "C" #endif -FFI_PLUGIN_EXPORT char * stockfish_stdout_read(); \ No newline at end of file +FFI_PLUGIN_EXPORT const char * stockfish_stdout_read(); \ No newline at end of file