From 8c4e45d4a773a2fa5ccfa9255e23270c9b2a6583 Mon Sep 17 00:00:00 2001 From: falkTX Date: Mon, 4 Jan 2016 23:37:09 +0000 Subject: [PATCH] Allow pre-allocated buffer in String class --- distrho/extra/String.hpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/distrho/extra/String.hpp b/distrho/extra/String.hpp index 6cf96d46..8f824f30 100644 --- a/distrho/extra/String.hpp +++ b/distrho/extra/String.hpp @@ -54,11 +54,20 @@ public: /* * Simple char string. */ - explicit String(char* const strBuf) noexcept + explicit String(char* const strBuf, const bool copyData = true) noexcept : fBuffer(_null()), fBufferLen(0) { - _dup(strBuf); + if (copyData || strBuf == nullptr) + { + _dup(strBuf); + } + else + { + fBuffer = strBuf; + fBufferLen = std::strlen(strBuf); + } + } /*