mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 03:30:37 +00:00
Avoiding leaking the popped item (#6193)
Set the deleted item to its zero val so it can be garbage collected.
This commit is contained in:
parent
099fb7c627
commit
31ec791d5a
@ -105,6 +105,7 @@ func (bp *PeersByMinBlock) Pop() interface{} {
|
||||
old := *bp
|
||||
n := len(old)
|
||||
x := old[n-1]
|
||||
old[n-1] = PeerRef{}
|
||||
*bp = old[0 : n-1]
|
||||
return x
|
||||
}
|
||||
|
@ -319,6 +319,7 @@ func (s *TxByPriceAndTime) Pop() interface{} {
|
||||
old := *s
|
||||
n := len(old)
|
||||
x := old[n-1]
|
||||
old[n-1] = nil
|
||||
*s = old[0 : n-1]
|
||||
return x
|
||||
}
|
||||
|
@ -211,6 +211,7 @@ func (t *transactionsByGasPrice) Pop() interface{} {
|
||||
old := t.txs
|
||||
n := len(old)
|
||||
x := old[n-1]
|
||||
old[n-1] = nil
|
||||
t.txs = old[0 : n-1]
|
||||
return x
|
||||
}
|
||||
@ -289,6 +290,7 @@ func (s *sortingHeap) Pop() interface{} {
|
||||
old := *s
|
||||
n := len(old)
|
||||
x := old[n-1]
|
||||
old[n-1] = nil
|
||||
*s = old[0 : n-1]
|
||||
return x
|
||||
}
|
||||
|
@ -70,6 +70,7 @@ func (h *expHeap) Pop() interface{} {
|
||||
old := *h
|
||||
n := len(old)
|
||||
x := old[n-1]
|
||||
old[n-1] = expItem{}
|
||||
*h = old[0 : n-1]
|
||||
return x
|
||||
}
|
||||
|
@ -87,6 +87,7 @@ func (lq *LinkQueue) Pop() interface{} {
|
||||
old := *lq
|
||||
n := len(old)
|
||||
x := old[n-1]
|
||||
old[n-1] = nil
|
||||
x.idx = -1
|
||||
x.queueId = NoQueue
|
||||
*lq = old[0 : n-1]
|
||||
@ -152,6 +153,7 @@ func (aq *AnchorQueue) Pop() interface{} {
|
||||
old := *aq
|
||||
n := len(old)
|
||||
x := old[n-1]
|
||||
old[n-1] = nil
|
||||
*aq = old[0 : n-1]
|
||||
x.idx = -1
|
||||
return x
|
||||
@ -243,6 +245,7 @@ func (iq *InsertQueue) Pop() interface{} {
|
||||
old := *iq
|
||||
n := len(old)
|
||||
x := old[n-1]
|
||||
old[n-1] = nil
|
||||
*iq = old[0 : n-1]
|
||||
x.idx = -1
|
||||
x.queueId = NoQueue
|
||||
|
Loading…
Reference in New Issue
Block a user