Skip to content

[BUG] Function updateValueCArray() does nothingΒ #932

@ybrenning

Description

@ybrenning

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

  1. Initialize a new CArray
  2. Populate with values such that an update operation is possible
  3. Print the contents of the array with displayCArray()
  4. Call the updateValueCArray() function with a valid index and value
  5. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions