On Wed, Jan 26, 2005 at 10:58:34AM +0000, Maulet wrote: > Vinod Joseph wrote: > > > >I used memcmp() instead of strcmp() since strcmp() creates some > >worries inside..gtk.. > > > >i think memcmp() is more efficient for usage in gtk compared to > >strcmp()..anyways the result is the same with the code.... > > > I think that the usage of memcmp() in your code is wrong. > You're doing something like: > > memcmp (x, y, strlen (x)); > > But if you want to know if two *strings* are *equal*, you should > consider the trailing '\0', so the right way would be: > > memcmp (x, y, strlen (x) + 1);
A good segfault recipe if y is shorter than x. Beside that, strlen() + memcmp() may be somewhat faster or somewhat slower than strcmp() when the strings are equal (depdens on implementation), but it's is order of magnitude(!) slower when the strings differ near their begining. The lesson is to use strcmp() for string comparison. Yeti -- Dynamic IP address is not a crime. _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list