The GLib library provides functionality which makes C more pleasant and convenient to use. It is used throughout the libraries of GTK+ and GNOME as well as in GNOME programs. The functionality provided by GNOME can basically be divided into four categories, portability, convenience functions, generic data structures, and the GLib main loop.
For portability, GLib provides portable equivalents for a number of functions that are available in some, but not all C libraries. For instance, GLib provides functions g_strcasecmp() and g_memmove() as portable equivalents for strcasecmp() and memmove(). On platforms where the standard functionality exists, the GLib functions will just wrap these functions, on other platforms, a portable implementation will be used.
GLib also provides a number of unique functions to make using C more convenient. For instance, it provides functions to break strings into words, to do computations with dates, and to log warning messages and error messages in a flexible fashion.
The generic data structures that GLib provides, such as linked lists, hash tables, balanced trees, and variable-length arrays, allow programmers to take advantage of sophisticated data structures and improve the efficiency of their programs without having to reimplement the data structures from scratch. For example, the GHashTable type allows a programmer to create a hash table for arbitrary objects by simply providing two functions, a function to compute hash values for the objects in the table and a function to compare two values.
The last major category of functionality that GLib provides is the GLib main loop. This is a generic and extensible implementation of an event loop. Standard event sources that GLib provides include timers, IO callbacks, and idle functions, but it is also possible to add completely new types of event sources into the GLib main loop. GDK uses this functionality to add an event source for X events. By not tying the main loop directly into the toolkit as is frequently done, GLib allows both graphical and non-graphical event-driven programs (an example of the latter would be a CORBA server) to use the same event loop.