2 * - By Richard W.M. Jones <rich@annexia.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the Free
16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 * $Id: tree.c,v 1.2 2002/10/08 15:10:28 rich Exp $
36 _tree_new (pool pool, size_t size)
38 tree t = (tree) new_vector (pool, tree);
40 t = prealloc (pool, t, sizeof (*t) + size);
47 copy_tree (pool pool, tree t)
49 tree nt = _tree_new (pool, t->size);
52 /* Copy the node data. */
53 memcpy (nt->data, t->data, t->size);
55 /* Copy each subnode, recursively. */
56 for (i = 0; i < tree_size (t); ++i)
61 nst = copy_tree (pool, st);
62 tree_push_back (nt, nst);
69 _tree_get_data (tree t, void *ptr)
71 if (ptr) memcpy (ptr, t->data, t->size);
75 _tree_set_data (tree t, const void *ptr)
77 if (ptr) memcpy (t->data, ptr, t->size);