-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Description
Description
The function updateValueCArray() in the implementation of arrays does not update anything.
Upon checking for a correct index in line 99, the function does not actually update the value at the given index. The function will return INVALID_POSITION if the element at the given position is not equal to zero instead of updating the value at the given index. I would like to fix this issue by updating the function.
Expected behavior
Element at index position should be updated to value and return SUCCESS upon doing so.
Actual behavior
No element gets updated and returns INVALID_POSITION even for valid positions.
Possible fix
Update the value at the given index using array->array[position] = value; and add a return statement
Steps to reproduce
- Initialize a new
CArray - Populate with values such that an update operation is possible
- Print the contents of the array with
displayCArray() - Call the
updateValueCArray()function with a valid index and value - Print the "updated" contents of the array with
displayCArray()
Context
I was trying to understand the implementation while reading through the source code and found this function which I could not make sense of
Additional information
No response