Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const entry = state.code[state.addresses[index]]
const edge = to + entry[SIZE]
sorted.remove(state.addresses, from)
state.code[from] = undefined
// clear out entries in what will be the new address range of the moved entry
var addr = edge - 1
while (addr >= to) {
const ix = sorted.lte(state.addresses, addr)
if (ix === -1) break
const match = state.addresses[ix]
addr = match - 1
// code previously cleared:
if (state.code[match] === undefined) {
sorted.remove(state.addresses, match)
continue
}
if (match + +state.code[match][SIZE] <= to) continue
sorted.remove(state.addresses, match)
state.code[match] = undefined
}
entry[START] = toAddr
state.code[to] = entry
sorted.add(state.addresses, to)
cb()
}
}
return function (row, cb) {
const [event, fromAddr, toAddr] = row
const from = parseInt(fromAddr, 16)
const to = parseInt(toAddr, 16)
const index = sorted.lte(state.addresses, from)
if (index === -1) {
opts.warn(`${event} address ${fromAddr} not found`)
cb()
return
}
const entry = state.code[state.addresses[index]]
const edge = to + entry[SIZE]
sorted.remove(state.addresses, from)
state.code[from] = undefined
// clear out entries in what will be the new address range of the moved entry
var addr = edge - 1
while (addr >= to) {
const ix = sorted.lte(state.addresses, addr)
if (ix === -1) break
const match = state.addresses[ix]
addr = match - 1
// code previously cleared:
if (state.code[match] === undefined) {
sorted.remove(state.addresses, match)
continue
}
if (match + +state.code[match][SIZE] <= to) continue
return function (row, cb) {
const [event, start] = row
const addr = parseInt(start, 16)
const success = sorted.remove(state.addresses, addr)
if (success === true) {
state.code[addr] = undefined
cb()
} else {
state.opts.warn(`${event} address ${start} not found`)
cb()
}
}
}
Set.prototype.del = function (idx) {
var entry = new Entry(idx, null)
sorted.remove(this._list, entry, cmp)
}