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
7void 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}
21
22/*
23 * The preprocess_sample method will return with reference counts for the
24 * in it, when done using (and perhaps getting ref counts if needing to
25 * keep a pointer to one of those entries) it must be paired with
26 * addr_location__put(), so that the refcounts can be decremented.
27 */
28void addr_location__exit(struct addr_location *al)
29{
30	map__zput(al->map);
31	thread__zput(al->thread);
32	maps__zput(al->maps);
33}
34
35void addr_location__copy(struct addr_location *dst, struct addr_location *src)
36{
37	thread__put(dst->thread);
38	maps__put(dst->maps);
39	map__put(dst->map);
40	*dst = *src;
41	dst->thread = thread__get(src->thread);
42	dst->maps = maps__get(src->maps);
43	dst->map = map__get(src->map);
44}
45