Update memory.go

This commit is contained in:
Felix Lange 2025-11-26 15:49:15 +01:00 committed by GitHub
parent c51e1b54a5
commit a688be7baf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -77,13 +77,13 @@ func (m *Memory) Set32(offset uint64, val *uint256.Int) {
val.PutUint256(m.store[offset:])
}
// Resize resizes the memory to size
// Resize grows the memory to the requested size.
func (m *Memory) Resize(size uint64) {
if uint64(m.Len()) < size {
if uint64(cap(m.store)) > size {
if uint64(len(m.store)) < size {
if uint64(cap(m.store)) >= size {
m.store = m.store[:size]
} else {
m.store = append(m.store, make([]byte, size-uint64(m.Len()))...)
m.store = append(m.store, make([]byte, size-uint64(len(m.store)))...)
}
}
}