]> git.proxmox.com Git - mirror_frr.git/blob - qpb/qpb_allocator.c
Merge pull request #13088 from donaldsharp/pim_use_after
[mirror_frr.git] / qpb / qpb_allocator.c
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * qpb_allocator.c
4 *
5 * @copyright Copyright (C) 2016 Sproute Networks, Inc.
6 *
7 * @author Avneesh Sachdev <avneesh@sproute.com>
8 */
9
10 #ifdef HAVE_CONFIG_H
11 #include "config.h"
12 #endif
13
14 #include "linear_allocator.h"
15
16 #include "qpb_allocator.h"
17
18 /*
19 * _qpb_alloc
20 */
21 static void *_qpb_alloc(void *allocator_data, size_t size)
22 {
23 return linear_allocator_alloc(allocator_data, size);
24 }
25
26 /*
27 * _qpb_free
28 */
29 static void _qpb_free(void *allocator_data, void *ptr)
30 {
31 linear_allocator_free(allocator_data, ptr);
32 }
33
34 static ProtobufCAllocator allocator_template = {_qpb_alloc, _qpb_free, NULL};
35
36 /*
37 * qpb_allocator_init_linear
38 *
39 * Initialize qpb_allocator_t with the given linear allocator.
40 */
41 void qpb_allocator_init_linear(qpb_allocator_t *allocator,
42 linear_allocator_t *linear_allocator)
43 {
44 *allocator = allocator_template;
45 allocator->allocator_data = linear_allocator;
46 }