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;
|
break;
|
||||||
|
|
||||||
rbytes = 0;
|
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);
|
err = g_io_channel_read(channel, (char *) buf, toread, &rbytes);
|
||||||
g_at_util_debug_chat(TRUE, (char *)buf, rbytes,
|
g_at_util_debug_chat(TRUE, (char *)buf, rbytes,
|
||||||
|
|
|
@ -123,7 +123,7 @@ static gboolean received_data(GIOChannel *channel, GIOCondition cond,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
rbytes = 0;
|
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);
|
err = g_io_channel_read(channel, (char *) buf, toread, &rbytes);
|
||||||
g_at_util_debug_dump(TRUE, buf, 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 avail = ring_buffer_avail(hdlc->write_buffer);
|
||||||
unsigned int wrap = ring_buffer_avail_no_wrap(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 char tail[3];
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
guint16 fcs = HDLC_INITFCS;
|
guint16 fcs = HDLC_INITFCS;
|
||||||
|
|
|
@ -944,7 +944,7 @@ static gboolean received_data(GIOChannel *channel, GIOCondition cond,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
rbytes = 0;
|
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);
|
err = g_io_channel_read(channel, (char *) buf, toread, &rbytes);
|
||||||
g_at_util_debug_chat(TRUE, (char *)buf, 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;
|
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)
|
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);
|
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
|
* Returns the write pointer with write offset specified by offset. Careful
|
||||||
* buffer. Use the ring_buffer_avail_no_wrap function,
|
* not to write past the end of the buffer. Use the ring_buffer_avail_no_wrap
|
||||||
* ring_buffer_write_advance.
|
* 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
|
* Returns the number of free bytes available in the buffer
|
||||||
|
|
Loading…
Reference in New Issue