Add epmapper commands to rpcclient
[Samba/gbeck.git] / source / include / talloc.h
blob433b52ec954ea13904f45d53179e34d16d60ed54
1 #ifndef _TALLOC_H_
2 #define _TALLOC_H_
3 /*
4 Unix SMB/CIFS implementation.
5 Samba temporary memory allocation functions
6 Copyright (C) Andrew Tridgell 2000
7 Copyright (C) 2001 by Martin Pool <mbp@samba.org>
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 /**
25 * @ingroup talloc
26 * @{
27 * @sa talloc.c
30 /**
31 * talloc allocation pool. All allocated blocks can be freed in one go.
32 **/
34 struct talloc_chunk {
35 struct talloc_chunk *next;
36 size_t size;
37 void *ptr;
40 struct talloc_ctx {
41 struct talloc_chunk *list;
42 size_t total_alloc_size;
44 /** The name recorded for this pool, if any. Should describe
45 * the purpose for which it was allocated. The string is
46 * allocated within the pool. **/
47 char *name;
49 /** Pointer to the next allocate talloc pool, so that we can
50 * summarize all talloc memory usage. **/
51 struct talloc_ctx *next_ctx;
54 typedef struct talloc_ctx TALLOC_CTX;
56 TALLOC_CTX *talloc_init(char const *fmt, ...) PRINTF_ATTRIBUTE(1, 2);
58 char *talloc_vasprintf(TALLOC_CTX *t, const char *fmt, va_list ap)
59 PRINTF_ATTRIBUTE(2, 0);
61 char *talloc_asprintf(TALLOC_CTX *t, const char *fmt, ...)
62 PRINTF_ATTRIBUTE(2, 3);
64 char *talloc_vasprintf_append(TALLOC_CTX *t, char *, const char *, va_list ap)
65 PRINTF_ATTRIBUTE(3, 0);
67 char *talloc_asprintf_append(TALLOC_CTX *t, char *, const char *, ...)
68 PRINTF_ATTRIBUTE(3, 4);
70 /** @} */
72 #endif /* ndef _TALLOC_H_ */