We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5b0d747 commit aa61e78Copy full SHA for aa61e78
xobjects/context.py
@@ -472,9 +472,13 @@ def grow(self, capacity):
472
self.capacity = newcapacity
473
474
def free(self, offset, size):
475
+ if offset < 0 or offset + size > self.capacity:
476
+ raise ValueError("Cannot free outside of buffer")
477
nch = Chunk(offset, offset + size)
478
# insert sorted
- if offset > self.chunks[-1].start: # new chuck at the end
479
+ if len(self.chunks) == 0:
480
+ self.chunks.append(nch)
481
+ elif offset > self.chunks[-1].start: # new chuck at the end
482
self.chunks.append(nch)
483
else: # new chuck needs to be inserted
484
for ic, ch in enumerate(self.chunks):
0 commit comments