summaryrefslogtreecommitdiff
path: root/monero_libwallet2_api_c/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'monero_libwallet2_api_c/src/main')
-rw-r--r--monero_libwallet2_api_c/src/main/cpp/helpers.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/monero_libwallet2_api_c/src/main/cpp/helpers.cpp b/monero_libwallet2_api_c/src/main/cpp/helpers.cpp
index d77995b..d4ca540 100644
--- a/monero_libwallet2_api_c/src/main/cpp/helpers.cpp
+++ b/monero_libwallet2_api_c/src/main/cpp/helpers.cpp
@@ -11,12 +11,19 @@
#include <cstring>
const char* vectorToString(const std::vector<std::string>& vec, const std::string separator) {
+ // Check if the vector is empty
+ if (vec.empty()) {
+ return "";
+ }
+
// Concatenate all strings in the vector
std::string result;
- for (const auto& str : vec) {
- result += str;
+ for (size_t i = 0; i < vec.size() - 1; ++i) {
+ result += vec[i];
result += separator;
}
+ result += vec.back(); // Append the last string without the separator
+
const char* cstr = result.c_str();
return cstr;
}