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!