Question 12 · 10 points
Dynamic integer collection
Implement append_unique.
typedef struct {
int *data;
size_t size;
size_t capacity;
} int_array_t;
int append_unique(
int_array_t *array,
int value
);
Add value only when it is not already present. Grow the allocation when size == capacity, preserve the existing allocation if realloc fails, and update size and capacity only after success. Return non-zero on success and 0 on allocation failure. Adding an existing value is successful but must not change the array.