source: branches/samba-3.2.x/source/include/talloc_stack.h

Last change on this file was 133, checked in by Paul Smedley, 17 years ago

Update trunk to 3.2.0pre3

File size: 1.7 KB
Line 
1/*
2 Unix SMB/CIFS implementation.
3 Implement a stack of talloc contexts
4 Copyright (C) Volker Lendecke 2007
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19*/
20
21/*
22 * Implement a stack of talloc frames.
23 *
24 * When a new talloc stackframe is allocated with talloc_stackframe(), then
25 * the TALLOC_CTX returned with talloc_tos() is reset to that new
26 * frame. Whenever that stack frame is TALLOC_FREE()'ed, then the reverse
27 * happens: The previous talloc_tos() is restored.
28 *
29 * This API is designed to be robust in the sense that if someone forgets to
30 * TALLOC_FREE() a stackframe, then the next outer one correctly cleans up and
31 * resets the talloc_tos().
32 *
33 */
34
35#ifndef _TALLOC_STACK_H
36#define _TALLOC_STACK_H
37
38#include "lib/talloc/talloc.h"
39
40/*
41 * Create a new talloc stack frame.
42 *
43 * When free'd, it frees all stack frames that were created after this one and
44 * not explicitly freed.
45 */
46
47TALLOC_CTX *talloc_stackframe(void);
48TALLOC_CTX *talloc_stackframe_pool(size_t poolsize);
49
50/*
51 * Get us the current top of the talloc stack.
52 */
53
54TALLOC_CTX *talloc_tos(void);
55
56#endif
Note: See TracBrowser for help on using the repository browser.