i saw a code example for dynamic memory c++ and have used the method in this function to allocate memory, is it an advisable way to do it? i never saw it eactly like this or maybe i have and forgotten.

Code:
void GetDrawNumbers(int tot_nums, int drawnums[])
{
    
    int allocsize = tot_nums;
    int* tempnums = new int[allocsize];

    //do stuff

    free(tempnums);


}