glib

Glib Data Structures

glib implements many common data structures, so you don’t have to reinvent the wheel every time you want a linked list. This section covers glib’s implementation of linked lists, sorted binary trees, N-ary trees, and hash tables. Lists glib provides generic single and doubly linked lists, GSList and GList, respectively. These are implemented as lists…

Glib String Handling

glib provides a number of functions for string handling; some are unique to glib, and some solve portability concerns. They all interoperate nicely with the glib memory allocation routines. For those interested in a better string than gchar*, there’s also a GString type. It isn’t covered in this book, but documentation is available at http://www.gtk.org/.

Glib Memory

glib wraps the standard malloc() and free() with its own g_ variants, g_malloc() and g_free(), shown in Figure 2-5. These are nice in several small ways: • g_malloc() always returns a gpointer, never a char*, so there’s no need to cast the return value. • g_malloc() aborts the program if the underlying malloc() fails, so…

Glib Debugging Macros

glib has a nice set of macros you can use to enforce invariants and preconditions in your code. GTK+ uses these liberally—one of the reasons it’s so stable and easy to use. They all disappear when you define G_DISABLE_CHECKS or G_DISABLE_ASSERT, so there’s no performance penalty in production code. Using these liberally is a very,…

Frequently Used Macros on Glib

glib defines a number of familiar macros used in many C programs, shown in Figure 2-1. All of these should be self-explanatory. MIN()/MAX() return the smaller or larger of their arguments. ABS() returns the absolute value of its argument. CLAMP(x, low, high) means x, unless x is outside the range [low, high]; if x is…

What is glib?

glib is a C portability and utility library for UNIX-like systems and Windows. This chapter covers some of the most commonly-used library features in GTK+ and Gnome applications. glib is simple, and the concepts are familiar; so we’ll move quickly. For more complete coverage of glib, see glib.h or the free glib reference manual that…

The Gnome Development Framework

Gnome’s application development framework centers around a suite of libraries, all written in portable ANSI C and intended to be used on UNIX-like systems. Libraries which involve graphics realy on the X Window System. Wrappers are available which export the Gnome API to nearly any language you can think of, including Ada, Scheme, Python, Perl,…