| 140 | } |
| 141 | |
| 142 | int pn_buffer_append(pn_buffer_t *buf, const char *bytes, size_t size) |
| 143 | { |
| 144 | if (!size) return 0; |
| 145 | int err = pn_buffer_ensure(buf, size); |
| 146 | if (err) return err; |
| 147 | |
| 148 | size_t tail = pni_buffer_tail(buf); |
| 149 | size_t tail_space = pni_buffer_tail_space(buf); |
| 150 | size_t n = pn_min(tail_space, size); |
| 151 | |
| 152 | // Heuristic check for a strange usage in messenger |
| 153 | if (bytes!=buf->bytes+tail) { |
| 154 | memcpy(buf->bytes + tail, bytes, n); |
| 155 | memcpy(buf->bytes, bytes + n, size - n); |
| 156 | } |
| 157 | buf->size += size; |
| 158 | |
| 159 | return 0; |
| 160 | } |
| 161 | |
| 162 | static size_t pni_buffer_index(pn_buffer_t *buf, size_t index) |
| 163 | { |
no test coverage detected