Use the platform-api in the correct order of operations. Also malloc the correct size for each struct, ua_session, ua_display and ua_window.