Harald Welte | 8e7fca3 | 2017-05-07 16:14:33 +0200 | [diff] [blame] | 1 | #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__) |
| 15 | void *_talloc_zero(const void *ctx, size_t size, const char *name); |
| 16 | |
| 17 | #define talloc_free(ctx) _talloc_free(ctx, __location__) |
| 18 | int _talloc_free(void *ptr, const char *location); |
| 19 | |
| 20 | /* Unsupported! */ |
| 21 | #define talloc_size(ctx, size) talloc_named_const(ctx, size, __location__) |
| 22 | void *talloc_named_const(const void *context, size_t size, const char *name); |
| 23 | void talloc_set_name_const(const void *ptr, const char *name); |
| 24 | char *talloc_strdup(const void *t, const char *p); |
| 25 | void *talloc_pool(const void *context, size_t size); |