In allocate_temp its failing at:
*out_temp = new_temp;
Which makes sense because in the first example youre passing in a pointer so out_temp becomes a pointer to a pointer I am pretty sure? Where as in the second example you did everything correctly.