Attempts to add the reply to the static buffer in the client struct. * Returns C_ERR if the buffer is full, or the reply list is not empty, * in which case the reply must be added to the reply list. */
| 291 | * Returns C_ERR if the buffer is full, or the reply list is not empty, |
| 292 | * in which case the reply must be added to the reply list. */ |
| 293 | int _addReplyToBuffer(client *c, const char *s, size_t len) { |
| 294 | size_t available = sizeof(c->buf)-c->bufpos; |
| 295 | |
| 296 | if (c->flags & CLIENT_CLOSE_AFTER_REPLY) return C_OK; |
| 297 | |
| 298 | /* If there already are entries in the reply list, we cannot |
| 299 | * add anything more to the static buffer. */ |
| 300 | if (listLength(c->reply) > 0) return C_ERR; |
| 301 | |
| 302 | /* Check that the buffer has enough space available for this string. */ |
| 303 | if (len > available) return C_ERR; |
| 304 | |
| 305 | memcpy(c->buf+c->bufpos,s,len); |
| 306 | c->bufpos+=len; |
| 307 | return C_OK; |
| 308 | } |
| 309 | |
| 310 | /* Adds the reply to the reply linked list. |
| 311 | * Note: some edits to this function need to be relayed to AddReplyFromClient. */ |
no test coverage detected