I have this test code :
void test2(){
    char** twoDArray = (char**)calloc(3,sizeof(char*));
    char* element1 = (char*)calloc(3,sizeof(char));
    twoDArray[0] = element1;    
    twoDArray[1] = element1;
    twoDArray[2] = element1;
    freeArray(twoDArray,3);
}
void freeArray(char** arr,int size){
    if(arr!= NULL){
        for(int i =0 ;i < size;i++){
            if(arr[i] != NULL){
                free(arr[i]);
                arr[i] = NULL;
            }
        }
        free(arr);
        arr = NULL;
    }
}
in second iteration of loop in freeArray arr[1] != NULL give 'true' and error occurs, why ? How to properly free such array ?
 
     
     
    