[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Patch: Thread safe obstack
From: |
Bruno Haible |
Subject: |
Re: Patch: Thread safe obstack |
Date: |
Mon, 27 Aug 2007 00:21:21 +0200 |
User-agent: |
KMail/1.5.4 |
Herbert Euler wrote:
> But I have many
> obstacks in my program, so I am having to choose one of them
> accordingly. ... That is why I want to call
> `obstack_alloc_failed_handler' with a user provided argument.
I fully agree that there is an issue here. If the obstack API was
designed today, the function obstack_alloc_failed_handler should get
passed either a user-provided value or the obstack itself (then the
user can look up a value by himself through a hash-table access).
But the facility of obstacks is in glibc for 10 years now. This means,
it will get hard for you to convince the glibc maintainers.
> The third one requires more libraries to be linked with and I do not want.
libtrampoline is tiny: less than 1 KB object code.
> However, there are other cases where there is no solutions, or the
> solutions are tricky. For example, if two obstacks are in two
> different type of objects which react differently to memory allocation
> failure, using a global `obstack_alloc_failed_handler' is a bad idea.
You can also put the memory allocation failure check into the memory
allocation function. You can specify this function through 'obstack_chunkfun'
for each obstack separately.
Bruno