aboutsummaryrefslogtreecommitdiff
path: root/thirdparty/ryml/src/c4/yml/common.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2026-02-24 15:02:58 +0100
committerGitHub Enterprise <[email protected]>2026-02-24 15:02:58 +0100
commit2af00d3ff720969fb3b4d471778efcf8c7b3fad4 (patch)
tree9193eb3ff8cc9f3fb5e3342d94bde8c193a977ce /thirdparty/ryml/src/c4/yml/common.cpp
parentadded zencore/filesystem.h include (diff)
parentVarious bug fixes (#778) (diff)
downloadzen-sb/spdlog-out.tar.xz
zen-sb/spdlog-out.zip
Merge branch 'main' into sb/spdlog-outsb/spdlog-out
Diffstat (limited to 'thirdparty/ryml/src/c4/yml/common.cpp')
-rw-r--r--thirdparty/ryml/src/c4/yml/common.cpp117
1 files changed, 0 insertions, 117 deletions
diff --git a/thirdparty/ryml/src/c4/yml/common.cpp b/thirdparty/ryml/src/c4/yml/common.cpp
deleted file mode 100644
index 75b873549..000000000
--- a/thirdparty/ryml/src/c4/yml/common.cpp
+++ /dev/null
@@ -1,117 +0,0 @@
-#include "c4/yml/common.hpp"
-
-#ifndef RYML_NO_DEFAULT_CALLBACKS
-# include <stdlib.h>
-# include <stdio.h>
-#endif // RYML_NO_DEFAULT_CALLBACKS
-
-namespace c4 {
-namespace yml {
-
-namespace {
-Callbacks s_default_callbacks;
-} // anon namespace
-
-#ifndef RYML_NO_DEFAULT_CALLBACKS
-void report_error_impl(const char* msg, size_t length, Location loc, FILE *f)
-{
- if(!f)
- f = stderr;
- if(loc)
- {
- if(!loc.name.empty())
- {
- fwrite(loc.name.str, 1, loc.name.len, f);
- fputc(':', f);
- }
- fprintf(f, "%zu:", loc.line);
- if(loc.col)
- fprintf(f, "%zu:", loc.col);
- if(loc.offset)
- fprintf(f, " (%zuB):", loc.offset);
- }
- fprintf(f, "%.*s\n", (int)length, msg);
- fflush(f);
-}
-
-void error_impl(const char* msg, size_t length, Location loc, void * /*user_data*/)
-{
- report_error_impl(msg, length, loc, nullptr);
- ::abort();
-}
-
-void* allocate_impl(size_t length, void * /*hint*/, void * /*user_data*/)
-{
- void *mem = ::malloc(length);
- if(mem == nullptr)
- {
- const char msg[] = "could not allocate memory";
- error_impl(msg, sizeof(msg)-1, {}, nullptr);
- }
- return mem;
-}
-
-void free_impl(void *mem, size_t /*length*/, void * /*user_data*/)
-{
- ::free(mem);
-}
-#endif // RYML_NO_DEFAULT_CALLBACKS
-
-
-
-Callbacks::Callbacks()
- :
- m_user_data(nullptr),
- #ifndef RYML_NO_DEFAULT_CALLBACKS
- m_allocate(allocate_impl),
- m_free(free_impl),
- m_error(error_impl)
- #else
- m_allocate(nullptr),
- m_free(nullptr),
- m_error(nullptr)
- #endif
-{
-}
-
-Callbacks::Callbacks(void *user_data, pfn_allocate alloc_, pfn_free free_, pfn_error error_)
- :
- m_user_data(user_data),
- #ifndef RYML_NO_DEFAULT_CALLBACKS
- m_allocate(alloc_ ? alloc_ : allocate_impl),
- m_free(free_ ? free_ : free_impl),
- m_error(error_ ? error_ : error_impl)
- #else
- m_allocate(alloc_),
- m_free(free_),
- m_error(error_)
- #endif
-{
- C4_CHECK(m_allocate);
- C4_CHECK(m_free);
- C4_CHECK(m_error);
-}
-
-
-void set_callbacks(Callbacks const& c)
-{
- s_default_callbacks = c;
-}
-
-Callbacks const& get_callbacks()
-{
- return s_default_callbacks;
-}
-
-void reset_callbacks()
-{
- set_callbacks(Callbacks());
-}
-
-void error(const char *msg, size_t msg_len, Location loc)
-{
- s_default_callbacks.m_error(msg, msg_len, loc, s_default_callbacks.m_user_data);
-}
-
-} // namespace yml
-} // namespace c4