We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
当数据写到buffer尾部时,如果队尾如果在写数据有问题
The text was updated successfully, but these errors were encountered:
ssize_t rb_write(struct ringbuffer *rb, const void *buf, size_t len) { if (!rb) { return -1; } int left = rb_get_space_free(rb); if ((int)len > left) { printf("Not enough space: %zu request, %d available\n", len, left); return -1; } // 这里修改过 #if 1 if((rb->length - rb->end) < len) { int firstLen = rb->length - rb->end; memcpy(rb_end_ptr(rb), buf, firstLen); rb->end = (rb->end + firstLen) % rb->length;
int secondLen = len - firstLen; memcpy(rb_end_ptr(rb), buf+firstLen, secondLen); rb->end = (rb->end + secondLen) % rb->length; } else { memcpy(rb_end_ptr(rb), buf, len); rb->end = (rb->end + len) % rb->length; }
#else memcpy(rb_end_ptr(rb), buf, len); rb->end = (rb->end + len) % rb->length; #endif
return len;
} 这样改的,我测试了可以循环写,不知道对不对
Sorry, something went wrong.
非常感谢,你是对的,已经fix了 b916cf6
No branches or pull requests
当数据写到buffer尾部时,如果队尾如果在写数据有问题
The text was updated successfully, but these errors were encountered: