MCPcopy Create free account
hub / github.com/apache/brpc / set_error

Method set_error

src/butil/status.cpp:90–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88}
89
90int Status::set_error(int c, const butil::StringPiece& error_msg) {
91 if (0 == c) {
92 free(_state);
93 _state = NULL;
94 return 0;
95 }
96 const size_t st_size = status_size(error_msg.size());
97 if (_state == NULL || _state->state_size < st_size) {
98 State* new_state = reinterpret_cast<State*>(malloc(st_size));
99 if (NULL == new_state) {
100 return -1;
101 }
102 new_state->state_size = st_size;
103 free(_state);
104 _state = new_state;
105 }
106 _state->code = c;
107 _state->size = error_msg.size();
108 memcpy(_state->message, error_msg.data(), error_msg.size());
109 _state->message[error_msg.size()] = '\0';
110 return 0;
111}
112
113Status::State* Status::copy_state(const State* s) {
114 const size_t n = status_size(s->size);

Callers

nothing calls this directly

Calls 3

status_sizeFunction · 0.85
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected