Re: [CFReview] Red-Black Tree

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема Re: [CFReview] Red-Black Tree
Дата
Msg-id 20100209140211.GA5522@alvh.no-ip.org
обсуждение исходный текст
Ответ на Re: [CFReview] Red-Black Tree  (Robert Haas <robertmhaas@gmail.com>)
Список pgsql-hackers
Robert Haas escribió:
> On Mon, Feb 8, 2010 at 3:05 PM, Alvaro Herrera
> <alvherre@commandprompt.com> wrote:

> > How do we now that it works?
> 
> Visual inspection?  It's not very complicated.

Well, that works if you assume the trivial/usual malloc/free coding
style, but it fails in the hypothetical scenario I described earlier.
You could as well say that each rbtree must provide a memory context
that is going to be deleted when the tree is freed, instead of freeing
nodes one by one (and in fact it looks more efficient to do it that way
... except that we'd have to get in the business of strcpy'ing the
node's data).  There's no way to know how this stuff is going to be
used, so if it's not going to be used now, I think we shouldn't
implement it.  That's why I looked at the knngist patch too.

But hey, not that i care all that much either -- it's not a lot of code;
a couple dozen lines at most, and not complex.

> > (What, for example, if we were to allocate multiple nodes in a single
> > palloc chunk?  I'm not familiar with this stuff but that seems
> > plausible)
> 
> Well, then you could have the freefunc do something ((MyStruct *)
> a)->is_allocated = false.

Hmm, but isn't "a" gone at that point?

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Yeb Havinga
Дата:
Сообщение: Re: Avoiding bad prepared-statement plans.
Следующее
От: Federico Di Gregorio
Дата:
Сообщение: About psycopg2 (by its author)