summaryrefslogtreecommitdiff
path: root/rb.h
diff options
context:
space:
mode:
authorOlivier Gayot <duskcoder@gmail.com>2013-12-23 19:51:14 +0100
committerOlivier Gayot <duskcoder@gmail.com>2014-01-18 13:44:28 +0100
commit68122955675e2b7a5652760d609b91eec34b80b7 (patch)
tree1d5b6ae1a5f15905b190177bf3b11319ab5be1ed /rb.h
parent646515d288da8aec7dc266f7d30047320b271742 (diff)
rb: t_rb has been renamed to rb_t
t_rb will be kept in the source files for backward compatibility. However, it will not have to be used anymore.
Diffstat (limited to 'rb.h')
-rw-r--r--rb.h20
1 files changed, 12 insertions, 8 deletions
diff --git a/rb.h b/rb.h
index 5b1e0e1..8a8eb0e 100644
--- a/rb.h
+++ b/rb.h
@@ -13,9 +13,13 @@ typedef struct t_ring_buffer {
size_t size_filled;
} t_ring_buffer;
+/* do not remove for backward compatibility */
typedef t_ring_buffer t_rb;
-static inline size_t rb_get_size(const t_rb *rb)
+typedef t_ring_buffer ring_buffer_t;
+typedef t_ring_buffer rb_t;
+
+static inline size_t rb_get_size(const rb_t *rb)
{
return sizeof(rb->buffer);
}
@@ -24,33 +28,33 @@ static inline size_t rb_get_size(const t_rb *rb)
* initializes rb with default values.
* returns 0 on success
*/
-int rb_init(t_rb *rb);
+int rb_init(rb_t *rb);
/* returns an initialized newly allocated ring buffer */
-__attribute((malloc)) t_rb *rb_new(void);
+__attribute((malloc)) rb_t *rb_new(void);
-void rb_delete(t_rb **);
+void rb_delete(rb_t **);
/* put n bytes of src into the ring buffer pointed by rb */
-t_rb *rb_put(t_rb *rb, const void *src, size_t n);
+rb_t *rb_put(rb_t *rb, const void *src, size_t n);
/*
* take at most n bytes from the ring buffer pointed by rb and
* put them into dest
*/
-size_t rb_get(t_rb *rb, void *dest, size_t n);
+size_t rb_get(rb_t *rb, void *dest, size_t n);
/*
* like rb_get but does not modify the ring_buffer (the bytes are kept
* in the ring_buffer)
*/
-size_t rb_peek(const t_rb *ring_buffer, void *dest, size_t size);
+size_t rb_peek(const rb_t *ring_buffer, void *dest, size_t size);
/*
* remove a maximum of n bytes from the ring buffer pointed to by rb
* the functions returns the number of bytes actually removed
*/
-static inline size_t rb_remove(t_rb *rb, size_t n)
+static inline size_t rb_remove(rb_t *rb, size_t n)
{
return rb_get(rb, NULL, n);
}