Quote Originally Posted by ljin View Post
Thanks sean and tabstop!

It does make more sense for me now.


Code:
sptr get_s_ptr(int *a_ptr)
{
	sptr ptr;

	ptr = malloc(sizeof(sptr));
	ptr = (sptr)((char*)a_ptr - offsetof(struct s, a));//good?
	return ptr;
}
It's better to use offsetof() for some aligned issues. I could free memory in the main. Thanks for great help!
It is not in any way, shape, or form correct to use malloc. Just assign ptr to be what it is supposed to be, which is what your second line does, and go.