Skip to content

Commit

Permalink
fix merge after in deallocate
Browse files Browse the repository at this point in the history
  • Loading branch information
bebbo committed Apr 11, 2022
1 parent 1eada7a commit 87aeed8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion amitools/vamos/lib/lexec/Alloc.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ def deallocate(ctx, mh_addr, blk_addr, num_bytes, check=False):
# sanity check
if blk_addr < mh.lower or (blk_addr + num_bytes - 1) > mh.upper:
log_exec.error("deallocate: block outside of mem header!")
return

if check:
validate(ctx, mh)
Expand All @@ -200,6 +201,7 @@ def deallocate(ctx, mh_addr, blk_addr, num_bytes, check=False):
# sanity check
if mh.free != 0:
log_exec.error("deallocate: internal error: first=0 but free!=0!")
return

# create new and only mem chunk in deallocated range
mc = MemChunk(0, num_bytes, blk_addr)
Expand Down Expand Up @@ -253,7 +255,7 @@ def deallocate(ctx, mh_addr, blk_addr, num_bytes, check=False):
log_exec.debug("grow cur: %s", mc)
# no merging possible -> create a new chunk between last and cur
else:
next_addr = mc.addr if mc is not None else 0
next_addr = mc.next if mc is not None else 0
mc_new = MemChunk(next_addr, num_bytes, blk_addr)
mc_new.write(ctx)
if mc_last:
Expand Down

0 comments on commit 87aeed8

Please sign in to comment.