Remove misplaced const

This commit is contained in:
Bailey Thompson
2017-10-19 19:56:21 -04:00
committed by GitHub
parent 2c9638a949
commit cea2826bc4
2 changed files with 42 additions and 42 deletions

View File

@@ -64,7 +64,7 @@ list list_init(const size_t data_size) {
*
* @return The amount of elements.
*/
int list_size(list me const) {
int list_size(list me) {
return me->space;
}
@@ -75,7 +75,7 @@ int list_size(list me const) {
*
* @return If the list is empty.
*/
bool list_is_empty(list me const) {
bool list_is_empty(list me) {
return list_size(me) == 0;
}
@@ -85,7 +85,7 @@ bool list_is_empty(list me const) {
* @param array The array to copy the list to.
* @param me The list to copy to the array.
*/
void list_to_array(void *const array, list me const) {
void list_to_array(void *const array, list me) {
struct node *traverse = me->head;
int offset = 0;
while (traverse != NULL) {
@@ -98,7 +98,7 @@ void list_to_array(void *const array, list me const) {
/*
* Get the node at index starting from the head.
*/
static struct node *get_node_from_head(list me const, const int index) {
static struct node *get_node_from_head(list me, const int index) {
struct node *traverse = me->head;
for (int i = 0; i < index; i++) {
traverse = traverse->next;
@@ -109,7 +109,7 @@ static struct node *get_node_from_head(list me const, const int index) {
/*
* Get the node at index starting from tail.
*/
static struct node *get_node_from_tail(list me const, const int index) {
static struct node *get_node_from_tail(list me, const int index) {
struct node *traverse = me->tail;
for (int i = me->space - 1; i > index; i--) {
traverse = traverse->prev;
@@ -120,7 +120,7 @@ static struct node *get_node_from_tail(list me const, const int index) {
/*
* Get the node at the specified index.
*/
static struct node *get_node_at(list me const, const int index) {
static struct node *get_node_at(list me, const int index) {
if (index <= me->space / 2) {
return get_node_from_head(me, index);
} else {
@@ -137,7 +137,7 @@ static struct node *get_node_at(list me const, const int index) {
* @return 0 No error.
* -ENOMEM Out of memory.
*/
int list_add_first(list me const, void *const data) {
int list_add_first(list me, void *const data) {
struct node *const traverse = me->head;
struct node *const add = malloc(sizeof(struct node));
if (add == NULL) {
@@ -173,7 +173,7 @@ int list_add_first(list me const, void *const data) {
* -ENOMEM Out of memory.
* -EINVAL Invalid argument.
*/
int list_add_at(list me const, const int index, void *const data) {
int list_add_at(list me, const int index, void *const data) {
if (index < 0 || index > me->space) {
return -EINVAL;
}
@@ -212,7 +212,7 @@ int list_add_at(list me const, const int index, void *const data) {
* @return 0 No error.
* -ENOMEM Out of memory.
*/
int list_add_last(list me const, void *const data) {
int list_add_last(list me, void *const data) {
struct node *const traverse = me->tail;
struct node *const add = malloc(sizeof(struct node));
if (add == NULL) {
@@ -237,7 +237,7 @@ int list_add_last(list me const, void *const data) {
/*
* Determines if the input is illegal.
*/
static bool isIllegalInput(list me const, const int index) {
static bool isIllegalInput(list me, const int index) {
return index < 0 || index >= me->space || me->space == 0;
}
@@ -249,7 +249,7 @@ static bool isIllegalInput(list me const, const int index) {
* @return 0 No error.
* -EINVAL Invalid argument.
*/
int list_remove_first(list me const) {
int list_remove_first(list me) {
return list_remove_at(me, 0);
}
@@ -262,7 +262,7 @@ int list_remove_first(list me const) {
* @return 0 No error.
* -EINVAL Invalid argument.
*/
int list_remove_at(list me const, const int index) {
int list_remove_at(list me, const int index) {
if (isIllegalInput(me, index)) {
return -EINVAL;
}
@@ -290,7 +290,7 @@ int list_remove_at(list me const, const int index) {
* @return 0 No error.
* -EINVAL Invalid argument.
*/
int list_remove_last(list me const) {
int list_remove_last(list me) {
return list_remove_at(me, me->space - 1);
}
@@ -303,7 +303,7 @@ int list_remove_last(list me const) {
* @return 0 No error.
* -EINVAL Invalid argument.
*/
int list_set_first(list me const, void *const data) {
int list_set_first(list me, void *const data) {
return list_set_at(me, 0, data);
}
@@ -317,7 +317,7 @@ int list_set_first(list me const, void *const data) {
* @return 0 No error.
* -EINVAL Invalid argument.
*/
int list_set_at(list me const, const int index, void *const data) {
int list_set_at(list me, const int index, void *const data) {
if (isIllegalInput(me, index)) {
return -EINVAL;
}
@@ -335,7 +335,7 @@ int list_set_at(list me const, const int index, void *const data) {
* @return 0 No error.
* -EINVAL Invalid argument.
*/
int list_set_last(list me const, void *const data) {
int list_set_last(list me, void *const data) {
return list_set_at(me, me->space - 1, data);
}
@@ -348,7 +348,7 @@ int list_set_last(list me const, void *const data) {
* @return 0 No error.
* -EINVAL Invalid argument.
*/
int list_get_first(void *const data, list me const) {
int list_get_first(void *const data, list me) {
return list_get_at(data, me, 0);
}
@@ -362,7 +362,7 @@ int list_get_first(void *const data, list me const) {
* @return 0 No error.
* -EINVAL Invalid argument.
*/
int list_get_at(void *const data, list me const, const int index) {
int list_get_at(void *const data, list me, const int index) {
if (isIllegalInput(me, index)) {
return -EINVAL;
}
@@ -380,7 +380,7 @@ int list_get_at(void *const data, list me const, const int index) {
* @return 0 No error.
* -EINVAL Invalid argument.
*/
int list_get_last(void *const data, list me const) {
int list_get_last(void *const data, list me) {
return list_get_at(data, me, me->space - 1);
}
@@ -389,7 +389,7 @@ int list_get_last(void *const data, list me const) {
*
* @param me The list to clear.
*/
void list_clear(list me const) {
void list_clear(list me) {
struct node *traverse = me->head;
while (traverse != NULL) {
struct node *const temp = traverse;
@@ -408,7 +408,7 @@ void list_clear(list me const) {
*
* @return NULL
*/
list list_destroy(list me const) {
list list_destroy(list me) {
list_clear(me);
free(me);
return NULL;

View File

@@ -64,7 +64,7 @@ vector vector_init(const size_t data_size) {
*
* @return The size being used by the vector.
*/
int vector_size(vector me const) {
int vector_size(vector me) {
return me->offset;
}
@@ -75,7 +75,7 @@ int vector_size(vector me const) {
*
* @return If the vector is empty.
*/
bool vector_is_empty(vector me const) {
bool vector_is_empty(vector me) {
return vector_size(me) == 0;
}
@@ -87,7 +87,7 @@ bool vector_is_empty(vector me const) {
*
* @return If big enough.
*/
bool vector_ensure_capacity(vector me const, const int capacity) {
bool vector_ensure_capacity(vector me, const int capacity) {
return capacity <= me->space;
}
@@ -102,7 +102,7 @@ bool vector_ensure_capacity(vector me const, const int capacity) {
* @return 0 No error.
* -ENOMEM Out of memory.
*/
int vector_set_space(vector me const, const int size) {
int vector_set_space(vector me, const int size) {
me->space = size;
if (me->space < me->offset) {
me->offset = me->space;
@@ -123,7 +123,7 @@ int vector_set_space(vector me const, const int size) {
* @return 0 No error.
* -ENOMEM Out of memory.
*/
int vector_trim_to_size(vector me const) {
int vector_trim_to_size(vector me) {
return vector_set_space(me, me->offset);
}
@@ -133,7 +133,7 @@ int vector_trim_to_size(vector me const) {
* @param me The vector to copy from.
* @param array The array to copy to.
*/
void vector_to_array(void *const array, vector me const) {
void vector_to_array(void *const array, vector me) {
memcpy(array, me->storage, me->offset * me->data_size);
}
@@ -146,7 +146,7 @@ void vector_to_array(void *const array, vector me const) {
* @return 0 No error.
* -ENOMEM Out of memory.
*/
int vector_add_first(vector me const, void *const data) {
int vector_add_first(vector me, void *const data) {
return vector_add_at(me, 0, data);
}
@@ -161,7 +161,7 @@ int vector_add_first(vector me const, void *const data) {
* -ENOMEM Out of memory.
* -EINVAL Invalid argument.
*/
int vector_add_at(vector me const, const int index, void *const data) {
int vector_add_at(vector me, const int index, void *const data) {
if (index < 0 || index > me->offset) {
return -EINVAL;
}
@@ -193,14 +193,14 @@ int vector_add_at(vector me const, const int index, void *const data) {
* @return 0 No error.
* -ENOMEM Out of memory.
*/
int vector_add_last(vector me const, void *const data) {
int vector_add_last(vector me, void *const data) {
return vector_add_at(me, me->offset, data);
}
/*
* Determines if the input is illegal.
*/
static bool isIllegalInput(vector me const, const int index) {
static bool isIllegalInput(vector me, const int index) {
return index < 0 || index >= me->offset || me->offset == 0;
}
@@ -212,7 +212,7 @@ static bool isIllegalInput(vector me const, const int index) {
* @return 0 No error.
* -EINVAL Invalid argument.
*/
int vector_remove_first(vector me const) {
int vector_remove_first(vector me) {
return vector_remove_at(me, 0);
}
@@ -225,7 +225,7 @@ int vector_remove_first(vector me const) {
* @return 0 No error.
* -EINVAL Invalid argument.
*/
int vector_remove_at(vector me const, const int index) {
int vector_remove_at(vector me, const int index) {
if (isIllegalInput(me, index)) {
return -EINVAL;
}
@@ -244,7 +244,7 @@ int vector_remove_at(vector me const, const int index) {
* @return 0 No error.
* -EINVAL Invalid argument.
*/
int vector_remove_last(vector me const) {
int vector_remove_last(vector me) {
if (me->offset == 0) {
return -EINVAL;
}
@@ -260,7 +260,7 @@ int vector_remove_last(vector me const) {
* @return 0 No error.
* -EINVAL Invalid argument.
*/
int vector_set_first(vector me const, void *const data) {
int vector_set_first(vector me, void *const data) {
return vector_set_at(me, 0, data);
}
@@ -273,7 +273,7 @@ int vector_set_first(vector me const, void *const data) {
* @return 0 No error.
* -EINVAL Invalid argument.
*/
int vector_set_at(vector me const, const int index, void *const data) {
int vector_set_at(vector me, const int index, void *const data) {
if (isIllegalInput(me, index)) {
return -EINVAL;
}
@@ -289,7 +289,7 @@ int vector_set_at(vector me const, const int index, void *const data) {
* @return 0 No error.
* -EINVAL Invalid argument.
*/
int vector_set_last(vector me const, void *const data) {
int vector_set_last(vector me, void *const data) {
return vector_set_at(me, me->offset - 1, data);
}
@@ -302,7 +302,7 @@ int vector_set_last(vector me const, void *const data) {
* @return 0 No error.
* -EINVAL Invalid argument.
*/
int vector_get_first(void *const data, vector me const) {
int vector_get_first(void *const data, vector me) {
return vector_get_at(data, me, 0);
}
@@ -316,7 +316,7 @@ int vector_get_first(void *const data, vector me const) {
* @return 0 No error.
* -EINVAL Invalid argument.
*/
int vector_get_at(void *const data, vector me const, const int index) {
int vector_get_at(void *const data, vector me, const int index) {
if (isIllegalInput(me, index)) {
return -EINVAL;
}
@@ -333,7 +333,7 @@ int vector_get_at(void *const data, vector me const, const int index) {
* @return 0 No error.
* -EINVAL Invalid argument.
*/
int vector_get_last(void *const data, vector me const) {
int vector_get_last(void *const data, vector me) {
return vector_get_at(data, me, me->offset - 1);
}
@@ -345,7 +345,7 @@ int vector_get_last(void *const data, vector me const) {
* @return 0 No error.
* -ENOMEM Out of memory.
*/
int vector_clear(vector me const) {
int vector_clear(vector me) {
const int ret = vector_set_space(me, START_SPACE);
me->offset = 0;
return ret;
@@ -358,7 +358,7 @@ int vector_clear(vector me const) {
*
* @return NULL
*/
vector vector_destroy(vector me const) {
vector vector_destroy(vector me) {
free(me->storage);
me->storage = NULL;
free(me);