From ca914eb17bfdb2e56a39951a96a9fb54e1a5f607 Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Mon, 16 May 2016 17:05:36 +0200 Subject: lib: Add missing modulo calculation Adds a missing modulo calculation that would result in index -1 being returned instead of zero when the ringbuffer skipped back to the beginning. --- include/ouroboros/shm_du_map.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'include/ouroboros/shm_du_map.h') diff --git a/include/ouroboros/shm_du_map.h b/include/ouroboros/shm_du_map.h index f575aa42..35d85b11 100644 --- a/include/ouroboros/shm_du_map.h +++ b/include/ouroboros/shm_du_map.h @@ -47,18 +47,18 @@ void shm_du_map_close(struct shm_du_map * dum); void shm_du_map_destroy(struct shm_du_map * dum); /* returns the index of the buffer in the DU map */ -int shm_create_du_buff(struct shm_du_map * dum, - size_t size, - size_t headspace, - uint8_t * data, - size_t len); +ssize_t shm_create_du_buff(struct shm_du_map * dum, + size_t size, + size_t headspace, + uint8_t * data, + size_t len); /* FIXME: revise these */ -int shm_du_map_read_sdu(uint8_t ** dst, - struct shm_du_map * dum, - size_t idx); -int shm_release_du_buff(struct shm_du_map * dum, size_t idx); - +int shm_du_map_read_sdu(uint8_t ** dst, + struct shm_du_map * dum, + ssize_t idx); +int shm_release_du_buff(struct shm_du_map * dum, + ssize_t idx); /* FIXME: use shm_du_map * and index */ uint8_t * shm_du_buff_head_alloc(struct shm_du_buff * sdb, -- cgit v1.2.3