summaryrefslogtreecommitdiff
path: root/src/llama-impl.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/llama-impl.h')
-rw-r--r--src/llama-impl.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/llama-impl.h b/src/llama-impl.h
index dcc8c1c1..399b134a 100644
--- a/src/llama-impl.h
+++ b/src/llama-impl.h
@@ -24,3 +24,18 @@ void llama_log_callback_default(ggml_log_level level, const char * text, void *
#define LLAMA_LOG_INFO(...) llama_log_internal(GGML_LOG_LEVEL_INFO , __VA_ARGS__)
#define LLAMA_LOG_WARN(...) llama_log_internal(GGML_LOG_LEVEL_WARN , __VA_ARGS__)
#define LLAMA_LOG_ERROR(...) llama_log_internal(GGML_LOG_LEVEL_ERROR, __VA_ARGS__)
+
+//
+// helpers
+//
+
+static void replace_all(std::string & s, const std::string & search, const std::string & replace) {
+ if (search.empty()) {
+ return; // Avoid infinite loop if 'search' is an empty string
+ }
+ size_t pos = 0;
+ while ((pos = s.find(search, pos)) != std::string::npos) {
+ s.replace(pos, search.length(), replace);
+ pos += replace.length();
+ }
+}