MCPcopy Create free account
hub / github.com/boostorg/histogram / write

Method write

src/python/serialization_suite.hpp:38–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36 }
37
38 std::streamsize write(const char* s, std::streamsize n) {
39 if (len_ == 0) {
40 *pstr_ = PyBytes_FromStringAndSize(s, n);
41 if (*pstr_ == nullptr) // no point trying to recover from allocation error
42 std::terminate();
43 len_ = n;
44 } else {
45 if (pos_ + n > len_) {
46 len_ = pos_ + n;
47 if (_PyBytes_Resize(pstr_, len_) == -1)
48 std::terminate(); // no point trying to recover from allocation error
49 }
50 char* b = PyBytes_AS_STRING(*pstr_);
51 std::copy(s, s + n, b + pos_);
52 }
53 pos_ += n;
54 return n;
55 }
56
57private:
58 PyObject** pstr_;

Callers 1

sync_code.pyFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected