1620be847SIan Rogers // SPDX-License-Identifier: GPL-2.0 2620be847SIan Rogers #include "addr_location.h" 3620be847SIan Rogers #include "map.h" 4*0dd5041cSIan Rogers #include "maps.h" 5620be847SIan Rogers #include "thread.h" 6620be847SIan Rogers addr_location__init(struct addr_location * al)7*0dd5041cSIan Rogersvoid addr_location__init(struct addr_location *al) 8*0dd5041cSIan Rogers { 9*0dd5041cSIan Rogers al->thread = NULL; 10*0dd5041cSIan Rogers al->maps = NULL; 11*0dd5041cSIan Rogers al->map = NULL; 12*0dd5041cSIan Rogers al->sym = NULL; 13*0dd5041cSIan Rogers al->srcline = NULL; 14*0dd5041cSIan Rogers al->addr = 0; 15*0dd5041cSIan Rogers al->level = 0; 16*0dd5041cSIan Rogers al->filtered = 0; 17*0dd5041cSIan Rogers al->cpumode = 0; 18*0dd5041cSIan Rogers al->cpu = 0; 19*0dd5041cSIan Rogers al->socket = 0; 20*0dd5041cSIan Rogers } 21*0dd5041cSIan Rogers 22620be847SIan Rogers /* 23620be847SIan Rogers * The preprocess_sample method will return with reference counts for the 24620be847SIan Rogers * in it, when done using (and perhaps getting ref counts if needing to 25620be847SIan Rogers * keep a pointer to one of those entries) it must be paired with 26620be847SIan Rogers * addr_location__put(), so that the refcounts can be decremented. 27620be847SIan Rogers */ addr_location__exit(struct addr_location * al)28*0dd5041cSIan Rogersvoid addr_location__exit(struct addr_location *al) 29620be847SIan Rogers { 30620be847SIan Rogers map__zput(al->map); 31620be847SIan Rogers thread__zput(al->thread); 32*0dd5041cSIan Rogers maps__zput(al->maps); 33*0dd5041cSIan Rogers } 34*0dd5041cSIan Rogers addr_location__copy(struct addr_location * dst,struct addr_location * src)35*0dd5041cSIan Rogersvoid addr_location__copy(struct addr_location *dst, struct addr_location *src) 36*0dd5041cSIan Rogers { 37*0dd5041cSIan Rogers thread__put(dst->thread); 38*0dd5041cSIan Rogers maps__put(dst->maps); 39*0dd5041cSIan Rogers map__put(dst->map); 40*0dd5041cSIan Rogers *dst = *src; 41*0dd5041cSIan Rogers dst->thread = thread__get(src->thread); 42*0dd5041cSIan Rogers dst->maps = maps__get(src->maps); 43*0dd5041cSIan Rogers dst->map = map__get(src->map); 44620be847SIan Rogers } 45