Comments (2)
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;
}
这样改的,我测试了可以循环写,不知道对不对
from gear-lib.
非常感谢,你是对的,已经fix了
b916cf6
from gear-lib.
Related Issues (20)
- MSYS2 doesn't need pthreads4w HOT 1
- libposix4win.h HOT 1
- libhash.c - failed to build on MSYS2 HOT 1
- 谁能教教 libp2p库怎么用啊 HOT 2
- Fetching live camera stream HOT 2
- UCRT_INCLUDE_FILE(stdio.h) HOT 6
- libserialize.c中serializer_file_init方法 HOT 1
- Doesn't build on Cygwin! HOT 1
- Doesn't build on MSYS2!
- libhash的get_and_del返回值是不是有问题? HOT 1
- 大佬,问一下 config_util.h 中区分字符串和整型的逻辑,不太清楚 HOT 1
- build.sh cannot compile libhash (because of dependence on libstrex)
- memory leaks in MP4_ReadBox_sample_soun
- memory leaks in MP4_ReadBox_sample_vide
- allocator out of memory in MP4_ReadBox_stts
- heap_buffer_overflow in MP4_ReadLengthDescriptor
- libsock: pointer al is checked for nullness after dereferencing
- Unable to build on MSYS2 (UCRT64) HOT 1
- Unable to build on MSYS2 (CLANG64) HOT 1
- Have a look at your cmake_env.inc HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gear-lib.