1 // SPDX-License-Identifier: GPL-2.0
2 #include "addr_location.h"
3 #include "map.h"
4 #include "maps.h"
5 #include "thread.h"
6 
addr_location__init(struct addr_location * al)7 void addr_location__init(struct addr_location *al)
8 {
9 	al->thread = NULL;
10 	al->maps = NULL;
11 	al->map = NULL;
12 	al->sym = NULL;
13 	al->srcline = NULL;
14 	al->addr = 0;
15 	al->level = 0;
16 	al->filtered = 0;
17 	al->cpumode = 0;
18 	al->cpu = 0;
19 	al->socket = 0;
20 	al->parallelism = 1;
21 }
22 
23 /*
24  * The preprocess_sample method will return with reference counts for the
25  * in it, when done using (and perhaps getting ref counts if needing to
26  * keep a pointer to one of those entries) it must be paired with
27  * addr_location__put(), so that the refcounts can be decremented.
28  */
addr_location__exit(struct addr_location * al)29 void addr_location__exit(struct addr_location *al)
30 {
31 	map__zput(al->map);
32 	thread__zput(al->thread);
33 	maps__zput(al->maps);
34 }
35 
addr_location__copy(struct addr_location * dst,struct addr_location * src)36 void addr_location__copy(struct addr_location *dst, struct addr_location *src)
37 {
38 	thread__put(dst->thread);
39 	maps__put(dst->maps);
40 	map__put(dst->map);
41 	*dst = *src;
42 	dst->thread = thread__get(src->thread);
43 	dst->maps = maps__get(src->maps);
44 	dst->map = map__get(src->map);
45 }
46