I when running the following code,I get Realloc() Error : invalid next size error
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#define ENLRAGE_SIZE(size) size = size + 10
int checkEndOfFile();
int numIsInArray(int *arr, int num);
/*------
get_set()
Gets the input of the int numbers arranges the set
1. Gets the input (Assumption is that input is valid, as stated in the course booklet)
2. Checks each int value (seperated by whitespace) if has been entered before
3. If hasn't been entered, inputs the value to an array of ints
4. Once reaches EOF terminates the function and returns the array adress
-------*/
int *get_set(){
int inputNum;
int *setArray = malloc(11);
int valuesInArray;
int currentArraySize = 11;
*setArray = 0; /*setArray[0] - is the counter of the number of values entered */
printf("Hello! please enter a list of full numbers, with whitespace (space or enter) seperating"\
" each number from the other\n");
while(!checkEndOfFile()){
scanf("%d",&inputNum);
if(!numIsInArray(setArray,inputNum)){
valuesInArray = *setArray;
if(valuesInArray == currentArraySize - 1){
ENLRAGE_SIZE(currentArraySize);
setArray = (int *)realloc(setArray, currentArraySize);
}/*if(valuesInArray == currentArraySize)*/
*(setArray + valuesInArray + 1 ) = inputNum;
*setArray += 1;/* increasing the numbers counter*/
}/*if(!numIsInArray(setArry,num))*/
}/* while(!checkEndOfFile())*/
...
Why I do get this error and how can I fix it?
Tried to realloc space that was already malloc'ed.