Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your profile (name, country/region, and company) is displayed to the public and will accompany any content you post. You may update your IBM account at any time.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Manage C data using the GLib collections

Open source library adds a wide range of useful data utilities

Tom Copeland (tom@infoether.com), Developer, InfoEther
Tom Copeland started programming in BASIC on a TRS-80 Model III, but demand for that skill has waned and he now mostly writes Ruby, C, and Java code. He contributes to various open source projects, including PMD and GForge, and he helps administer RubyForge, an open source Ruby project repository. He and his wife, Alina, have five children (Maria, Tommy, Anna, Sarah, and Steven) and live in Virginia. You can contact Tom at tom@infoether.com.

Summary:  In this tutorial, learn how to use the GLib collection data structures to effectively manage data within C programs. In particular, you'll see how to use GLib's built-in data structures/containers -- linked lists, hash tables, arrays, trees, queues, and relations -- to fill the need for them in C.

Date:  28 Jun 2005
Level:  Intermediate PDF:  A4 and Letter (165 KB | 54 pages)Get Adobe® Reader®

Activity:  83983 views
Comments:  

Wrapup

Summary

In this tutorial you've seen how to use the data structures found in the GLib library. You've seen how you can use these containers to effectively manage your program's data, and you've seen how several popular open source projects use these containers as well. Along the way you've also gotten familiar with many of the GLib types, macros, and string handling functions.

GLib contains a lot of other neat functionality: it's got a threading-abstraction layer, a portable-sockets layer, message-logging utilities, date and time functions, file utilities, random-number generation, and much more. Exploring any of these modules would be worthwhile. And if you're feeling generous, you could even improve some of the documentation -- for example, the documentation for the lexical scanner includes a comment about how it needs some example code and more detail. If you've benefited from open source code, don't forget to lend a hand in improving it!


Acknowledgments

Many thanks to Sven Neumann, Simon Budig, Tim Ringenbach, and Michael Meeks for their helpful feedback on the "real world" GLib usages shown in this tutorial.

10 of 12 | Previous | Next

Comments



static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Linux, Open source
ArticleID=132891
TutorialTitle=Manage C data using the GLib collections
publish-date=06282005
author1-email=tom@infoether.com
author1-email-cc=jaloi@us.ibm.com