Added malloc / free helpers

2 helpers for allocating and freeing c structs. This is useful for when a c structs doesn't have a helper function to construct it, such as `pthread`.

I'm not certain if this is correct, feedback welcome :)