mirror of git://git.sysmocom.de/ofono
Add offset parameter to ring_buffer_write_ptr() function
This commit is contained in:
parent
9fd7d841c8
commit
8f05535bb2
|
@ -711,7 +711,7 @@ static gboolean received_data(GIOChannel *channel, GIOCondition cond,
|
|||
break;
|
||||
|
||||
rbytes = 0;
|
||||
buf = ring_buffer_write_ptr(chat->buf);
|
||||
buf = ring_buffer_write_ptr(chat->buf, 0);
|
||||
|
||||
err = g_io_channel_read(channel, (char *) buf, toread, &rbytes);
|
||||
g_at_util_debug_chat(TRUE, (char *)buf, rbytes,
|
||||
|
|
|
@ -123,7 +123,7 @@ static gboolean received_data(GIOChannel *channel, GIOCondition cond,
|
|||
break;
|
||||
|
||||
rbytes = 0;
|
||||
buf = ring_buffer_write_ptr(hdlc->read_buffer);
|
||||
buf = ring_buffer_write_ptr(hdlc->read_buffer, 0);
|
||||
|
||||
err = g_io_channel_read(channel, (char *) buf, toread, &rbytes);
|
||||
g_at_util_debug_dump(TRUE, buf, rbytes,
|
||||
|
@ -319,7 +319,7 @@ gboolean g_at_hdlc_send(GAtHDLC *hdlc, const unsigned char *data, gsize size)
|
|||
{
|
||||
unsigned int avail = ring_buffer_avail(hdlc->write_buffer);
|
||||
unsigned int wrap = ring_buffer_avail_no_wrap(hdlc->write_buffer);
|
||||
unsigned char *buf = ring_buffer_write_ptr(hdlc->write_buffer);
|
||||
unsigned char *buf = ring_buffer_write_ptr(hdlc->write_buffer, 0);
|
||||
unsigned char tail[3];
|
||||
unsigned int i = 0;
|
||||
guint16 fcs = HDLC_INITFCS;
|
||||
|
|
|
@ -944,7 +944,7 @@ static gboolean received_data(GIOChannel *channel, GIOCondition cond,
|
|||
break;
|
||||
|
||||
rbytes = 0;
|
||||
buf = ring_buffer_write_ptr(server->read_buf);
|
||||
buf = ring_buffer_write_ptr(server->read_buf, 0);
|
||||
|
||||
err = g_io_channel_read(channel, (char *) buf, toread, &rbytes);
|
||||
g_at_util_debug_chat(TRUE, (char *)buf, rbytes,
|
||||
|
|
|
@ -90,9 +90,10 @@ int ring_buffer_write(struct ring_buffer *buf, const void *data,
|
|||
return len;
|
||||
}
|
||||
|
||||
unsigned char *ring_buffer_write_ptr(struct ring_buffer *buf)
|
||||
unsigned char *ring_buffer_write_ptr(struct ring_buffer *buf,
|
||||
unsigned int offset)
|
||||
{
|
||||
return buf->buffer + buf->in % buf->size;
|
||||
return buf->buffer + (buf->in + offset) % buf->size;
|
||||
}
|
||||
|
||||
int ring_buffer_avail_no_wrap(struct ring_buffer *buf)
|
||||
|
|
|
@ -56,11 +56,12 @@ int ring_buffer_write(struct ring_buffer *buf, const void *data,
|
|||
int ring_buffer_write_advance(struct ring_buffer *buf, unsigned int len);
|
||||
|
||||
/*!
|
||||
* Returns the write pointer. Careful not to write past the end of the
|
||||
* buffer. Use the ring_buffer_avail_no_wrap function,
|
||||
* ring_buffer_write_advance.
|
||||
* Returns the write pointer with write offset specified by offset. Careful
|
||||
* not to write past the end of the buffer. Use the ring_buffer_avail_no_wrap
|
||||
* function, and ring_buffer_write_advance.
|
||||
*/
|
||||
unsigned char *ring_buffer_write_ptr(struct ring_buffer *buf);
|
||||
unsigned char *ring_buffer_write_ptr(struct ring_buffer *buf,
|
||||
unsigned int offset);
|
||||
|
||||
/*!
|
||||
* Returns the number of free bytes available in the buffer
|
||||
|
|
Loading…
Reference in New Issue