Free memory outside function
Yes and no.

As you've used it here, I don't see a memory leak, so that would be a "no."

The function itself, however allocates memory without ever freeing it, so it's pretty much a memory leak waiting to happen -- the client code has to free the memory it allocates. Worse, freeing that memory is slightly non-trivial (two separate frees that have to happen in the right order) so it's not just a matter of whoever uses it remembering to free the memory, but there's also a possibility of them doing it wrong even if they do remember. Granted, it's not terribly complex either, but I'd still probably add a little function like:

void destroy_sent_packet(pack *p) { 
    free(p-&gt;message);
    free(p);
}


So it's at least back to the client just remembering to free the memory.