diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/patree.c | 3 | ||||
-rw-r--r-- | src/ring.c | 15 |
2 files changed, 6 insertions, 12 deletions
diff --git a/src/patree.c b/src/patree.c index b8fd183..0cb74d3 100644 --- a/src/patree.c +++ b/src/patree.c @@ -289,7 +289,6 @@ change_index_c(const char* a, const char* b, size_t len) static inline int change_index_sse(const char* a, const char* b, const size_t len) { - int ret; for (size_t i = 0; i < len; i += sizeof(__m128i)) { const __m128i r = _mm_loadu_si128((const __m128i*)(a + i)); const __m128i* s = (const __m128i*)(b + i); @@ -297,7 +296,7 @@ change_index_sse(const char* a, const char* b, const size_t len) r, *s, _SIDD_SBYTE_OPS|_SIDD_CMP_EQUAL_EACH|_SIDD_NEGATIVE_POLARITY); if (index != sizeof(__m128i)) { - int ret = i + index; + size_t ret = i + index; if (ret > len) { ret = len; } @@ -14,7 +14,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include <assert.h> #include <stdint.h> #include <stdlib.h> #include <string.h> @@ -70,8 +69,6 @@ zix_ring_new(uint32_t size) ring->size = next_power_of_two(size); ring->size_mask = ring->size - 1; ring->buf = malloc(ring->size); - assert(zix_ring_read_space(ring) == 0); - assert(zix_ring_write_space(ring) == ring->size - 1); return ring; } @@ -103,7 +100,7 @@ zix_ring_reset(ZixRing* ring) static inline uint32_t read_space_internal(const ZixRing* ring, uint32_t r, uint32_t w) { - if (w > r) { + if (r < w) { return w - r; } else { return (w - r + ring->size) & ring->size_mask; @@ -119,12 +116,12 @@ zix_ring_read_space(const ZixRing* ring) static inline uint32_t write_space_internal(const ZixRing* ring, uint32_t r, uint32_t w) { - if (w > r) { + if (r == w) { + return ring->size - 1; + } else if (r < w) { return ((r - w + ring->size) & ring->size_mask) - 1; - } else if (w < r) { - return (r - w) - 1; } else { - return ring->size - 1; + return (r - w) - 1; } } @@ -212,8 +209,6 @@ zix_ring_write(ZixRing* ring, const void* src, uint32_t size) ring->write_head = (w + size) & ring->size_mask; } else { const uint32_t this_size = ring->size - w; - assert(this_size < size); - assert(w + this_size <= ring->size); memcpy(&ring->buf[w], src, this_size); memcpy(&ring->buf[0], (char*)src + this_size, size - this_size); ZIX_WRITE_BARRIER(); |