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
|
old := *bp
|
||||||
n := len(old)
|
n := len(old)
|
||||||
x := old[n-1]
|
x := old[n-1]
|
||||||
|
old[n-1] = PeerRef{}
|
||||||
*bp = old[0 : n-1]
|
*bp = old[0 : n-1]
|
||||||
return x
|
return x
|
||||||
}
|
}
|
||||||
|
@ -319,6 +319,7 @@ func (s *TxByPriceAndTime) Pop() interface{} {
|
|||||||
old := *s
|
old := *s
|
||||||
n := len(old)
|
n := len(old)
|
||||||
x := old[n-1]
|
x := old[n-1]
|
||||||
|
old[n-1] = nil
|
||||||
*s = old[0 : n-1]
|
*s = old[0 : n-1]
|
||||||
return x
|
return x
|
||||||
}
|
}
|
||||||
|
@ -211,6 +211,7 @@ func (t *transactionsByGasPrice) Pop() interface{} {
|
|||||||
old := t.txs
|
old := t.txs
|
||||||
n := len(old)
|
n := len(old)
|
||||||
x := old[n-1]
|
x := old[n-1]
|
||||||
|
old[n-1] = nil
|
||||||
t.txs = old[0 : n-1]
|
t.txs = old[0 : n-1]
|
||||||
return x
|
return x
|
||||||
}
|
}
|
||||||
@ -289,6 +290,7 @@ func (s *sortingHeap) Pop() interface{} {
|
|||||||
old := *s
|
old := *s
|
||||||
n := len(old)
|
n := len(old)
|
||||||
x := old[n-1]
|
x := old[n-1]
|
||||||
|
old[n-1] = nil
|
||||||
*s = old[0 : n-1]
|
*s = old[0 : n-1]
|
||||||
return x
|
return x
|
||||||
}
|
}
|
||||||
|
@ -70,6 +70,7 @@ func (h *expHeap) Pop() interface{} {
|
|||||||
old := *h
|
old := *h
|
||||||
n := len(old)
|
n := len(old)
|
||||||
x := old[n-1]
|
x := old[n-1]
|
||||||
|
old[n-1] = expItem{}
|
||||||
*h = old[0 : n-1]
|
*h = old[0 : n-1]
|
||||||
return x
|
return x
|
||||||
}
|
}
|
||||||
|
@ -87,6 +87,7 @@ func (lq *LinkQueue) Pop() interface{} {
|
|||||||
old := *lq
|
old := *lq
|
||||||
n := len(old)
|
n := len(old)
|
||||||
x := old[n-1]
|
x := old[n-1]
|
||||||
|
old[n-1] = nil
|
||||||
x.idx = -1
|
x.idx = -1
|
||||||
x.queueId = NoQueue
|
x.queueId = NoQueue
|
||||||
*lq = old[0 : n-1]
|
*lq = old[0 : n-1]
|
||||||
@ -152,6 +153,7 @@ func (aq *AnchorQueue) Pop() interface{} {
|
|||||||
old := *aq
|
old := *aq
|
||||||
n := len(old)
|
n := len(old)
|
||||||
x := old[n-1]
|
x := old[n-1]
|
||||||
|
old[n-1] = nil
|
||||||
*aq = old[0 : n-1]
|
*aq = old[0 : n-1]
|
||||||
x.idx = -1
|
x.idx = -1
|
||||||
return x
|
return x
|
||||||
@ -243,6 +245,7 @@ func (iq *InsertQueue) Pop() interface{} {
|
|||||||
old := *iq
|
old := *iq
|
||||||
n := len(old)
|
n := len(old)
|
||||||
x := old[n-1]
|
x := old[n-1]
|
||||||
|
old[n-1] = nil
|
||||||
*iq = old[0 : n-1]
|
*iq = old[0 : n-1]
|
||||||
x.idx = -1
|
x.idx = -1
|
||||||
x.queueId = NoQueue
|
x.queueId = NoQueue
|
||||||
|
Loading…
Reference in New Issue
Block a user