mirror of
https://github.com/cesanta/mongoose.git
synced 2024-12-27 06:51:04 +08:00
commit
f4def36ccb
@ -184,7 +184,7 @@ static void q_copyout(struct queue *q, uint8_t *buf, size_t len, size_t tail) {
|
||||
|
||||
static bool q_write(struct queue *q, const void *buf, size_t len) {
|
||||
bool success = false;
|
||||
size_t left = q->len - q->head + q->tail;
|
||||
size_t left = (q->len - q->head + q->tail -1) % q->len;
|
||||
if (len + sizeof(size_t) <= left) {
|
||||
q_copyin(q, (uint8_t *) &len, sizeof(len), q->head);
|
||||
q_copyin(q, (uint8_t *) buf, len, (q->head + sizeof(size_t)) % q->len);
|
||||
|
@ -6472,7 +6472,7 @@ static void q_copyout(struct queue *q, uint8_t *buf, size_t len, size_t tail) {
|
||||
|
||||
static bool q_write(struct queue *q, const void *buf, size_t len) {
|
||||
bool success = false;
|
||||
size_t left = q->len - q->head + q->tail;
|
||||
size_t left = (q->len - q->head + q->tail -1) % q->len;
|
||||
if (len + sizeof(size_t) <= left) {
|
||||
q_copyin(q, (uint8_t *) &len, sizeof(len), q->head);
|
||||
q_copyin(q, (uint8_t *) buf, len, (q->head + sizeof(size_t)) % q->len);
|
||||
|
Loading…
x
Reference in New Issue
Block a user