#include "src/stdio/printf_core/string_writer.h"
#include "src/stdio/printf_core/core_structs.h"
#include "src/string/memory_utils/memcpy_implementations.h"
#include <stddef.h>
namespace __llvm_libc {
namespace printf_core {
void StringWriter::write(const char *__restrict to_write, size_t len) {
if (len > available_capacity)
len = available_capacity;
if (len > 0) {
inline_memcpy(cur_buffer, to_write, len);
cur_buffer += len;
available_capacity -= len;
}
}
int write_to_string(void *raw_pointer, const char *__restrict to_write,
size_t len) {
StringWriter *string_writer = reinterpret_cast<StringWriter *>(raw_pointer);
string_writer->write(to_write, len);
return WRITE_OK;
}
}
}