Make object pointer const in object_exist function

This commit is contained in:
abdelrahman committed 2023-08-06 22:12:52 +01:00
1 parent 475cd59e45
commit 866aaa9011
1 file changed
+3 -2
+3 -2
View File
@@ -23,7 +23,7 @@ struct object_store {
ObjectID reusable_ids[MAX_OBJ_COUNT];
};
bool object_exists(ObjectStore *os, void *object);
bool object_exists(ObjectStore *os, const void *object);
ObjectStore *create_object_store() {
ObjectStore *os = (ObjectStore *)malloc(sizeof(ObjectStore));
@@ -107,6 +107,7 @@ void remove_object_from_store(ObjectStore *os, ObjectID *id_ptr) {
// Figure out how much we need to decrement the count. Since, a lot of
// objects may have been removed, the count needs to equal the last active
// object.
// cppcheck-suppress unsignedPositive
for (size_t i = id - 1; i >= 0; --i) {
if (os->object_ptrs[i]) {
new_count = i + 1;
@@ -175,7 +176,7 @@ void destroy_object_store(ObjectStore **os) {
*os = NULL;
}
bool object_exists(ObjectStore *os, void *object) {
bool object_exists(ObjectStore *os, const void *object) {
// This is a crude implementation for checking that an object has already
// been added.
// TODO (Abdelrahman): Figure out if there is a better way of doing this