blob: 625355aa366da1428c20ae2d2ef1ff2cba83c366 [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>
Harald Welte63c9e1f2019-12-14 21:11:39 +010020#include <stdio.h>
Harald Welte8e7fca32017-05-07 16:14:33 +020021#include <stdarg.h>
22
23/* minimalistic emulation of core talloc API functions used by msgb.c */
24
25#define __TALLOC_STRING_LINE1__(s) #s
26#define __TALLOC_STRING_LINE2__(s) __TALLOC_STRING_LINE1__(s)
27#define __TALLOC_STRING_LINE3__ __TALLOC_STRING_LINE2__(__LINE__)
28#define __location__ __FILE__ ":" __TALLOC_STRING_LINE3__
29
30#define talloc_zero(ctx, type) (type *)_talloc_zero(ctx, sizeof(type), #type)
31#define talloc_zero_size(ctx, size) _talloc_zero(ctx, size, __location__)
32void *_talloc_zero(const void *ctx, size_t size, const char *name);
33
34#define talloc_free(ctx) _talloc_free(ctx, __location__)
35int _talloc_free(void *ptr, const char *location);
36
37/* Unsupported! */
38#define talloc_size(ctx, size) talloc_named_const(ctx, size, __location__)
39void *talloc_named_const(const void *context, size_t size, const char *name);
40void talloc_set_name_const(const void *ptr, const char *name);
41char *talloc_strdup(const void *t, const char *p);
42void *talloc_pool(const void *context, size_t size);
Harald Welte63c9e1f2019-12-14 21:11:39 +010043void talloc_report(const void *ptr, FILE *f);