MCPcopy
hub / github.com/borgbackup/borg / resize

Method resize

src/borg/helpers/datastruct.py:33–43  ·  view source on GitHub ↗

Resize the buffer. To avoid frequent reallocation, we usually grow (if needed). By giving init=True it is possible to initialize for the first time or shrink the buffer. If a buffer size beyond the limit is requested, raise Buffer.MemoryLimitExceeded (OSError).

(self, size, init=False)

Source from the content-addressed store, hash-verified

31 return len(self.buffer)
32
33 def resize(self, size, init=False):
34 """
35 Resize the buffer. To avoid frequent reallocation, we usually grow (if needed).
36 By giving init=True it is possible to initialize for the first time or shrink the buffer.
37 If a buffer size beyond the limit is requested, raise Buffer.MemoryLimitExceeded (OSError).
38 """
39 size = int(size)
40 if self.limit is not None and size > self.limit:
41 raise Buffer.MemoryLimitExceeded(size, self.limit)
42 if init or len(self) < size:
43 self.buffer = self.allocator(size)
44
45 def get(self, size=None, init=False):
46 """

Callers 6

__init__Method · 0.95
getMethod · 0.95
test_resizeMethod · 0.95
test_limitMethod · 0.95

Calls

no outgoing calls

Tested by 4

test_resizeMethod · 0.76
test_limitMethod · 0.76