summaryrefslogtreecommitdiff
path: root/code/core/rbuf.c
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2017-07-21 00:33:35 +0200
committerUros Majstorovic <majstor@majstor.org>2017-07-21 00:33:35 +0200
commitd580fc0e00bf4b7acd3f9ee3345fad32223b40db (patch)
treef1b128e938ea37a437d1ec05686e5abc2b724238 /code/core/rbuf.c
parent50a392349a2e06ea5ff08e35cfb2558a1c97b993 (diff)
send ring buffer implementation; not done
Diffstat (limited to 'code/core/rbuf.c')
-rw-r--r--code/core/rbuf.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/code/core/rbuf.c b/code/core/rbuf.c
index 54843fa..d6c9c6e 100644
--- a/code/core/rbuf.c
+++ b/code/core/rbuf.c
@@ -4,7 +4,11 @@
int ecp_rbuf_init(ECPRBuffer *rbuf, ECPRBMessage *msg, unsigned int msg_size) {
rbuf->msg = msg;
- rbuf->msg_size = msg_size;
+ if (msg_size) {
+ rbuf->msg_size = msg_size;
+ } else {
+ rbuf->msg_size = ECP_RBUF_SEQ_HALF;
+ }
return ECP_OK;
}
@@ -20,6 +24,8 @@ int ecp_rbuf_msg_idx(ECPRBuffer *rbuf, ecp_seq_t seq) {
ssize_t ecp_rbuf_msg_store(ECPRBuffer *rbuf, ecp_seq_t seq, unsigned char *msg, size_t msg_size, unsigned char test_flags, unsigned char set_flags) {
int idx = ecp_rbuf_msg_idx(rbuf, seq);
if (idx < 0) return idx;
+
+ if (rbuf->msg == NULL) return 0;
if (test_flags && (test_flags & rbuf->msg[idx].flags)) return ECP_ERR_RBUF_FLAG;
memcpy(rbuf->msg[idx].msg, msg, msg_size);