You can do it this way:
void allocate( structure **ptr )
{
// Allocate memory for a single structure and put that address into the location
// that ptr points to. ptr is assumed to be the address of the pointer given
// by the caller
*ptr = malloc( sizeof(structure) );
}
So when you want to return a value in a parameter, you need to pass that variable's address in, then assign the value to what that address points to. Since, in this case, the variable is a pointer, you are passing in the address of a pointer or, in other words, a pointer to a pointer. Then the assignment *ptr =...
says to "assign an address to the pointer that this address points to".
Then to call it, you pass the ADDRESS of the pointer you want to be set:
structure *my_ptr;
// Put something useful in my_ptr, like the address of memory that will hold a structure
allocate( &my_ptr );
The important thing to remember in this case is that you are passing the location of the pointer, not the location of the data that the pointer is pointing to.