Is it required to free a variable before using realloc?
===

Is it necessary to free memory before using `realloc` again for a variable. Which of the following is correct?
    
    for(i = 0; i < n; i++){
       myArray = (int *)realloc(myArray, i*sizeof(int));
    }

    for(i = 0; i < n; i++){
       myArray = (int *)realloc(myArray, i*sizeof(int));
       free(myArray);
       myArray = NULL;
    }