From 96682a8284cc234207d2ba6a60b8f9939c17834f Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Thu, 25 Oct 2018 21:58:21 +0200 Subject: lib: Revise du buff API towards a memory allocator This changes the API to the rdrbuff to treat it as a pool memory allocator. The head and tailspace to allocate in a buffer is now set system-wide instead of being passed as a parameter. Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- include/ouroboros/shm_rdrbuff.h | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'include') diff --git a/include/ouroboros/shm_rdrbuff.h b/include/ouroboros/shm_rdrbuff.h index 49551497..dc8418fd 100644 --- a/include/ouroboros/shm_rdrbuff.h +++ b/include/ouroboros/shm_rdrbuff.h @@ -42,18 +42,16 @@ void shm_rdrbuff_destroy(struct shm_rdrbuff * rdrb); void shm_rdrbuff_purge(void); -/* returns the index of the buffer in the DU map */ -ssize_t shm_rdrbuff_write(struct shm_rdrbuff * rdrb, - size_t headspace, - size_t tailspace, - const uint8_t * data, - size_t data_len); +/* Returns block index, a ptr and du_buff. */ +ssize_t shm_rdrbuff_alloc(struct shm_rdrbuff * rdrb, + size_t count, + uint8_t ** ptr, + struct shm_du_buff ** sdb); -ssize_t shm_rdrbuff_write_b(struct shm_rdrbuff * rdrb, - size_t headspace, - size_t tailspace, - const uint8_t * data, - size_t data_len, +ssize_t shm_rdrbuff_alloc_b(struct shm_rdrbuff * rdrb, + size_t count, + uint8_t ** ptr, + struct shm_du_buff ** sdb, const struct timespec * abstime); ssize_t shm_rdrbuff_read(uint8_t ** dst, -- cgit v1.2.3