Coding Guidelines/Glib Utilities: Difference between revisions
Jump to navigation
Jump to search
(add docs link) |
(G_DEFINE_DEVICE is bogus) |
||
Line 1: | Line 1: | ||
Amanda links against the Glib library because it is full of useful utilities that make C code easier to read and write. However, Amanda's minimum version required is Glib-2.2.0, which was released in late 2002. Your development system probably contains a much more recent and featureful version of the library, but you cannot use any of those new features! Consult the [http://wiki.zmanda.com/glib-docs/ Glib-2.2.0 documentation] before using any glib features not listed below. | Amanda links against the Glib library because it is full of useful utilities that make C code easier to read and write. However, Amanda's minimum version required is Glib-2.2.0, which was released in late 2002. Your development system probably contains a much more recent and featureful version of the library, but you cannot use any of those new features! Consult the [http://wiki.zmanda.com/glib-docs/ Glib-2.2.0 documentation] before using any glib features not listed below. | ||
= Don't Use These = | |||
* G_DEFINE_TYPE doesn't work as expected in older versions - define the type manually. | |||
= Use These = | |||
Useful items from Glib: | Useful items from Glib: | ||
* GMainLoop (but avoid Glib's child watch source -- Amanda provides a replacement in event.h / {{pod|Amanda::MainLoop}}) | * GMainLoop (but avoid Glib's child watch source -- Amanda provides a replacement in event.h / {{pod|Amanda::MainLoop}}) |
Latest revision as of 17:30, 7 December 2009
Amanda links against the Glib library because it is full of useful utilities that make C code easier to read and write. However, Amanda's minimum version required is Glib-2.2.0, which was released in late 2002. Your development system probably contains a much more recent and featureful version of the library, but you cannot use any of those new features! Consult the Glib-2.2.0 documentation before using any glib features not listed below.
Don't Use These
- G_DEFINE_TYPE doesn't work as expected in older versions - define the type manually.
Use These
Useful items from Glib:
- GMainLoop (but avoid Glib's child watch source -- Amanda provides a replacement in event.h / Amanda::MainLoop)
- threads and thread pools
- memory allocation utilities such as g_new0
- logging functions
- string-handling functions (try to use either the Amanda string functions or Glib's, but not both, for the sake of readability)
- simple XML parser
- All sorts of data types:
- GSList (singly linked list)
- GList (doubly linked list)
- GHashTable
- GPtrArray (a resizeable array of generic pointers)
- GString