struct memory allocation problem