MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / write_format

Method write_format

examples/server/httplib.h:1642–1663  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1640
1641template <typename... Args>
1642inline ssize_t Stream::write_format(const char *fmt, const Args &...args) {
1643 const auto bufsiz = 2048;
1644 std::array<char, bufsiz> buf{};
1645
1646 auto sn = snprintf(buf.data(), buf.size() - 1, fmt, args...);
1647 if (sn <= 0) { return sn; }
1648
1649 auto n = static_cast<size_t>(sn);
1650
1651 if (n >= buf.size() - 1) {
1652 std::vector<char> glowable_buf(buf.size());
1653
1654 while (n >= glowable_buf.size() - 1) {
1655 glowable_buf.resize(glowable_buf.size() * 2);
1656 n = static_cast<size_t>(
1657 snprintf(&glowable_buf[0], glowable_buf.size() - 1, fmt, args...));
1658 }
1659 return write(&glowable_buf[0], n);
1660 } else {
1661 return write(buf.data(), n);
1662 }
1663}
1664
1665inline void default_socket_options(socket_t sock) {
1666 int yes = 1;

Callers 4

write_headersFunction · 0.80
write_response_coreMethod · 0.80
process_requestMethod · 0.80
write_requestMethod · 0.80

Calls 4

writeFunction · 0.50
dataMethod · 0.45
sizeMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected