views:

573

answers:

6

Hi,

Can you recommend peer reviewed libraries that I can use in C environment (something like Boost for C++) ? Something that provides hash, thread, interprocess communications, lists, smart memory management...

The environment is embedded system, not a very minimal system, but also not a PC!

Thanks! Amit

+4  A: 

I'm not sure if you'll find a single library that covers all of that... but you can check out glib and pthreads to cover a good bit of that.

Nicholas Mancuso
Nice. Adding to my list of things to look at.
jim
+6  A: 

+1 for GLib from me, too. Plus, it has its own threading API too, so you don't have to learn pthreads if you don't want to.

Not sure if there exists such a thing as "smart memory management" in C, it's not very easy when you don't have the safety nets of destructors and control over operators. But, again, GLib has plenty of memory-oriented data structures and stuff that really makes life easier.

And no, I'm not on the GLib team, but I really do like it. :)

unwind
+1  A: 

I'll jump on the GLib bandwagon too. Remember that C doesn't provide any syntactic sugar for complex data structures, so there are lots of casts and long function names in GLib, but it really does a great and efficient job with a little added verbosity!!

Dan
+3  A: 

Look at Boehm GC a widely used conservative garbage collector for C (or C++) that might serve your needs as far as smart memory management is concerned.

postfuturist
One should take care though when mixing GC with non-GC code, e.g. storing references to a GC block (one created with e.g. GC_MALLOC) only into non-GC (e.g. ones created with malloc) blocks will probably prematurely recollect that block! (At least according to the GC's semantics, didn't try it myself, please correct me if I'm wrong.)Wondering if there is some nice GC-aware utility library.
Paggas
+1  A: 

About the Glib use.

You probably can take what you need and cross-compile it. So if you just need the thread package - just compile that and don't take everything.

I'm doing the same thing with the Python VM. PyMite fits on a microcontroller and doesn't use all the functionality.

jim
+1  A: 

Check out the Apache Portable Runtime (APR) project.

Some of it's features:

  • memory management API
  • threads, mutexes
  • file I/O
  • atomic operations
  • hash tables, arrays
  • network sockets and protocol
  • shared memory, mmap

Not to mention it's portable.

the_void