Re: How to use obstack

From: Jonathan Bartlett (johnnyb_at_eskimo.com)
Date: 06/28/05


Date: Tue, 28 Jun 2005 08:55:00 -0400


> I have read "inside memory management"

For anyone who is interested, the URL is:

http://www-128.ibm.com/developerworks/linux/library/l-memory/

> I read the info of obstack, but do not understand well.
> For example, I do not know where obstack will be used, where it
> shouldn't be used; and how obstack works.

You should use them when you have a multi-stage operation, where objects
allocated in each stage do not survive past the stage, except where
specified explicitly.

Apache -- uses one pool per connection -- all resources are freed at the
end of the connection
GCC -- used to use obstacks for compilation, and used one obstack per
compilation unit
Samba -- uses one pool per connection

> By the way, there is Growing Objects in obstack, and I didn't
> understand after I read the info about it.Is there anyone give an
> example about the growing objects?

It's just if you don't know how much memory something is going to take
up, you can use a growing obstack to append data to it until you are
finished, and then get its final address.

Jon

----
Learn to program using Linux assembly language
http://www.cafeshops.com/bartlettpublish.8640017