| 111 | } |
| 112 | |
| 113 | Status::State* Status::copy_state(const State* s) { |
| 114 | const size_t n = status_size(s->size); |
| 115 | State* s2 = reinterpret_cast<State*>(malloc(n)); |
| 116 | if (NULL == s2) { |
| 117 | // TODO: If we failed to allocate, the status will be OK. |
| 118 | return NULL; |
| 119 | } |
| 120 | s2->code = s->code; |
| 121 | s2->size = s->size; |
| 122 | s2->state_size = n; |
| 123 | char* msg_head = s2->message; |
| 124 | memcpy(msg_head, s->message, s->size); |
| 125 | msg_head[s->size] = '\0'; |
| 126 | return s2; |
| 127 | }; |
| 128 | |
| 129 | std::string Status::error_str() const { |
| 130 | if (_state == NULL) { |
nothing calls this directly
no test coverage detected