Re: free binary search tree

Previous thread: how to type non latin in xterm?; video stream to watch FIFA World Cup? by Sviatoslav Chagaev on Monday, June 7, 2010 - 3:16 pm. (11 messages)

Next thread: pf: how to apply route-to for packets matching states? by Teemu Rinta-aho on Monday, June 7, 2010 - 4:32 pm. (4 messages)
From: Mark Bucciarelli
Date: Monday, June 7, 2010 - 2:02 pm

Hi,

On GNU/Linux, _GNU_SOURCE enables
tdestroy().  How do I free a binary tree in
OpenBSD?

I grepped /usr/src and didn't find any
places "tdelete(" is used.

Thanks,

m

From: Joachim Schipper
Date: Monday, June 7, 2010 - 2:20 pm

Can't you just do

    while (rootp != NULL)
        tdelete(rootp, &rootp, compar);

where, of course, compar() must be defined as usual for the tree
routines?

Note that the macros in sys/tree.h, which are available under the
liberal ISC (BSD) license and documented in tree(3), are usually
preferable to tsearch() and friends.

		Joachim

From: Bret S. Lambert
Date: Monday, June 7, 2010 - 2:21 pm

^^^^

$ man -k tdelete
tsearch, tfind, tdelete, twalk (3) - manipulate binary search trees

Previous thread: how to type non latin in xterm?; video stream to watch FIFA World Cup? by Sviatoslav Chagaev on Monday, June 7, 2010 - 3:16 pm. (11 messages)

Next thread: pf: how to apply route-to for packets matching states? by Teemu Rinta-aho on Monday, June 7, 2010 - 4:32 pm. (4 messages)