Optimizations and cleanup in libudev

Going through the code there are numerous places where the hand-written solutions to certain problems can be substituted with already available methods.

This Pull Request addresses these problems in a small manner, as it is my first to this project and I would like to know from you where I could improve my commits and coding-style before committing more.
I am looking forward to your feedback.