MCPcopy Create free account
hub / github.com/pybind/pybind11 / _sync

Method _sync

include/pybind11/iostream.h:94–115  ·  view source on GitHub ↗

This function must be non-virtual to be called in a destructor.

Source from the content-addressed store, hash-verified

92
93 // This function must be non-virtual to be called in a destructor.
94 int _sync() {
95 if (pbase() != pptr()) { // If buffer is not empty
96 gil_scoped_acquire tmp;
97 // This subtraction cannot be negative, so dropping the sign.
98 auto size = static_cast<size_t>(pptr() - pbase());
99 size_t remainder = utf8_remainder();
100
101 if (size > remainder) {
102 str line(pbase(), size - remainder);
103 pywrite(std::move(line));
104 pyflush();
105 }
106
107 // Copy the remainder at the end of the buffer to the beginning:
108 if (remainder > 0) {
109 std::memmove(pbase(), pptr() - remainder, remainder);
110 }
111 setp(pbase(), epptr());
112 pbump(static_cast<int>(remainder));
113 }
114 return 0;
115 }
116
117 int sync() override { return _sync(); }
118

Callers

nothing calls this directly

Calls 1

moveFunction · 0.85

Tested by

no test coverage detected