wayland: fix memory leaks
wayland/shm: rework format handling

Use a linked list for all supported formats and make the format table const.