blob: 0bd75d2c03baab13be2e1a2a86a81fa4d31e9803 [file] [log] [blame]
Kévin Redon9a12d682018-07-08 13:21:16 +02001/* Memory allocation library
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
16 */
Harald Welte8e7fca32017-05-07 16:14:33 +020017#pragma once
18
19#include <stdlib.h>
20#include <stdarg.h>
21
22/* minimalistic emulation of core talloc API functions used by msgb.c */
23
24#define __TALLOC_STRING_LINE1__(s) #s
25#define __TALLOC_STRING_LINE2__(s) __TALLOC_STRING_LINE1__(s)
26#define __TALLOC_STRING_LINE3__ __TALLOC_STRING_LINE2__(__LINE__)
27#define __location__ __FILE__ ":" __TALLOC_STRING_LINE3__
28
29#define talloc_zero(ctx, type) (type *)_talloc_zero(ctx, sizeof(type), #type)
30#define talloc_zero_size(ctx, size) _talloc_zero(ctx, size, __location__)
31void *_talloc_zero(const void *ctx, size_t size, const char *name);
32
33#define talloc_free(ctx) _talloc_free(ctx, __location__)
34int _talloc_free(void *ptr, const char *location);
35
36/* Unsupported! */
37#define talloc_size(ctx, size) talloc_named_const(ctx, size, __location__)
38void *talloc_named_const(const void *context, size_t size, const char *name);
39void talloc_set_name_const(const void *ptr, const char *name);
40char *talloc_strdup(const void *t, const char *p);
41void *talloc_pool(const void *context, size_t size);