blob: 04c1374540239581a2a92b062df6da8d9da11fb5 [file] [log] [blame]
Dave Barach32dcd3b2019-07-08 12:25:38 -04001/*
2 * Copyright (c) 2015 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#include <vppinfra/mem.h>
17
18/* Vector of all bihashes */
Damjan Mariondae1c7e2020-10-17 13:32:25 +020019__clib_export void **clib_all_bihashes;
Damjan Marionbfa75d62020-10-06 17:46:06 +020020static clib_mem_heap_t *clib_all_bihash_heap;
Dave Barach32dcd3b2019-07-08 12:25:38 -040021
Damjan Mariondae1c7e2020-10-17 13:32:25 +020022__clib_export clib_mem_heap_t *
Dave Barach32dcd3b2019-07-08 12:25:38 -040023clib_all_bihash_set_heap (void)
24{
25 if (PREDICT_FALSE (clib_all_bihash_heap == 0))
26 clib_all_bihash_heap = clib_mem_get_heap ();
27
28 return clib_mem_set_heap (clib_all_bihash_heap);
29}
30
31/*
32 * Leave it to Beaver to change the size of a bihash
33 * by making a clone in a stack local and then copying it...
34 */
Damjan Mariondae1c7e2020-10-17 13:32:25 +020035__clib_export void
Dave Barach32dcd3b2019-07-08 12:25:38 -040036clib_bihash_copied (void *dst, void *src)
37{
38 int i;
39
40 for (i = 0; i < vec_len (clib_all_bihashes); i++)
41 {
42 if (clib_all_bihashes[i] == src)
43 {
44 clib_all_bihashes[i] = dst;
45 return;
46 }
47 }
48 clib_warning ("Couldn't find bihash copy source %llx!", src);
49}
50
51
52/*
53 * fd.io coding-style-patch-verification: ON
54 *
55 * Local Variables:
56 * eval: (c-set-style "gnu")
57 * End:
58 */