From cd822fedfc1357919b6cba46a9b61e58e2fc1dde Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Thu, 20 Jul 2017 21:39:26 -0700 Subject: [PATCH] Fix several issues with includes and redundant comparisons. --- include/sprs.h | 1 + include/vec.h | 1 + src/sprs.c | 2 +- src/vec.c | 2 +- 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/sprs.h b/include/sprs.h index 12abc27..59582b0 100644 --- a/include/sprs.h +++ b/include/sprs.h @@ -1,6 +1,7 @@ #ifndef LIBDS_SPRS_HEADER #define LIBDS_SPRS_HEADER +#include #include "libds.h" /** diff --git a/include/vec.h b/include/vec.h index 69268b6..152210e 100644 --- a/include/vec.h +++ b/include/vec.h @@ -3,6 +3,7 @@ #define LIBDS_VEC_CAPACITY 4 +#include #include "libds.h" /** diff --git a/src/sprs.c b/src/sprs.c index e3efca1..305e01a 100644 --- a/src/sprs.c +++ b/src/sprs.c @@ -38,7 +38,7 @@ void sprs_put(sprs* sprs, int index, void* data){ } } int sprs_contains(sprs* sprs, int index){ - return index >= 0 && sprs->sparse[index].index >= 0 && sprs->sparse[index].index < sprs->size && sprs->dense[sprs->sparse[index].index] == index; + return index >= 0 && sprs->sparse[index].index < sprs->size && sprs->dense[sprs->sparse[index].index] == index; } void* sprs_get(sprs* sprs, int index){ void* data = NULL; diff --git a/src/vec.c b/src/vec.c index 0d769cc..82f86fe 100644 --- a/src/vec.c +++ b/src/vec.c @@ -92,7 +92,7 @@ int vec_foreach(vec* v, void* data, compare_func compare, foreach_func foreach, void* vec_index(vec* v, size_t index) { void* to_return = NULL; - if (index < v->capacity && index >= 0) { + if (index < v->capacity) { to_return = ((void**) v->data)[index]; } return to_return;