Kévin Redon | 9a12d68 | 2018-07-08 13:21:16 +0200 | [diff] [blame] | 1 | /* 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 Welte | 8e7fca3 | 2017-05-07 16:14:33 +0200 | [diff] [blame] | 17 | #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__) |
| 31 | void *_talloc_zero(const void *ctx, size_t size, const char *name); |
| 32 | |
| 33 | #define talloc_free(ctx) _talloc_free(ctx, __location__) |
| 34 | int _talloc_free(void *ptr, const char *location); |
| 35 | |
| 36 | /* Unsupported! */ |
| 37 | #define talloc_size(ctx, size) talloc_named_const(ctx, size, __location__) |
| 38 | void *talloc_named_const(const void *context, size_t size, const char *name); |
| 39 | void talloc_set_name_const(const void *ptr, const char *name); |
| 40 | char *talloc_strdup(const void *t, const char *p); |
| 41 | void *talloc_pool(const void *context, size_t size); |