]> git.proxmox.com Git - mirror_frr.git/blob - qpb/qpb_allocator.c
Merge remote-tracking branch 'origin/stable/3.0'
[mirror_frr.git] / qpb / qpb_allocator.c
1 /*
2 * qpb_allocator.c
3 *
4 * @copyright Copyright (C) 2016 Sproute Networks, Inc.
5 *
6 * @author Avneesh Sachdev <avneesh@sproute.com>
7 *
8 * This file is part of Quagga.
9 *
10 * Quagga is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2, or (at your option) any
13 * later version.
14 *
15 * Quagga is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License along
21 * with this program; see the file COPYING; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 */
24
25 #include "linear_allocator.h"
26
27 #include "qpb_allocator.h"
28
29 /*
30 * _qpb_alloc
31 */
32 static void *
33 _qpb_alloc (void *allocator_data, size_t size)
34 {
35 return linear_allocator_alloc (allocator_data, size);
36 }
37
38 /*
39 * _qpb_free
40 */
41 static void
42 _qpb_free (void *allocator_data, void *ptr)
43 {
44 linear_allocator_free (allocator_data, ptr);
45 }
46
47 static ProtobufCAllocator allocator_template = {
48 _qpb_alloc,
49 _qpb_free,
50 NULL,
51 8192,
52 NULL
53 };
54
55 /*
56 * qpb_allocator_init_linear
57 *
58 * Initialize qpb_allocator_t with the given linear allocator.
59 */
60 void
61 qpb_allocator_init_linear (qpb_allocator_t *allocator,
62 linear_allocator_t *linear_allocator)
63 {
64 *allocator = allocator_template;
65 allocator->allocator_data = linear_allocator;
66 }