On Wed, 15 Oct 2014 22:44:25 +0400 Dmitry Cherkassov <dcherkas...@gmail.com> wrote:
> Hi list! > > The definition of wl_display_interface symbol can come from > libwayland-server.so or libwayland-client.so. > > There is a code in closed source EGL implementation that does > interfaces comparison via pointers, yielding negative results when > addresses are different (one address is saved by QtWayland, the other > one is from &wl_display_interface in EGL source code). > > Is there a smarter way to compare wl_display_interface's? > > There is this function: > > wl_interface_equal(const struct wl_interface *a, const struct wl_interface *b) > { > return a == b || strcmp(a->name, b->name) == 0; > } > > But as you can see it's not safe to use it alone because in case of > bad pointer we will get undefined results. > > Currently struct wl_interface is the following: > struct wl_interface { > const char *name; > int version; > int method_count; > const struct wl_message *methods; > int event_count; > const struct wl_message *events; > }; > > Since there is no magic field at the beginning it is not possible to > see whether a pointer points to the valid wl_interface structure. > > So my question is: how can we compare wl_interfaces in more clever and > safer way? Hmm, why would you ever have a bad pointer? Bad pointers in general tend to cause crashes and stuff, so you shouldn't be having a bad one in the first place. What is the background for your question/problem? Thanks, pq _______________________________________________ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel