blob: f2d9666ef0aa1d2fcccd32fc1ab60e597cf66a55 [file] [log] [blame]
Harald Welte8e7fca32017-05-07 16:14:33 +02001#pragma once
2
3#include <stdlib.h>
4#include <stdarg.h>
5
6/* minimalistic emulation of core talloc API functions used by msgb.c */
7
8#define __TALLOC_STRING_LINE1__(s) #s
9#define __TALLOC_STRING_LINE2__(s) __TALLOC_STRING_LINE1__(s)
10#define __TALLOC_STRING_LINE3__ __TALLOC_STRING_LINE2__(__LINE__)
11#define __location__ __FILE__ ":" __TALLOC_STRING_LINE3__
12
13#define talloc_zero(ctx, type) (type *)_talloc_zero(ctx, sizeof(type), #type)
14#define talloc_zero_size(ctx, size) _talloc_zero(ctx, size, __location__)
15void *_talloc_zero(const void *ctx, size_t size, const char *name);
16
17#define talloc_free(ctx) _talloc_free(ctx, __location__)
18int _talloc_free(void *ptr, const char *location);
19
20/* Unsupported! */
21#define talloc_size(ctx, size) talloc_named_const(ctx, size, __location__)
22void *talloc_named_const(const void *context, size_t size, const char *name);
23void talloc_set_name_const(const void *ptr, const char *name);
24char *talloc_strdup(const void *t, const char *p);
25void *talloc_pool(const void *context, size_t size);