| 1 |
def _OutputBuffer_InitAndGrow(buffer, ob, max_length): |
| 2 |
res, ob.dst = buffer.init_and_grow(max_length) |
| 3 |
ob.size = res |
| 4 |
ob.pos = 0 |
| 5 |
|
| 6 |
|
| 7 |
def _OutputBuffer_InitWithSize(buffer, ob, max_length, init_size): |
| 8 |
# Get block size |
| 9 |
if 0 <= max_length < init_size: |
| 10 |
block_size = max_length |
| 11 |
else: |
| 12 |
block_size = init_size |
| 13 |
|
| 14 |
res, ob.dst = buffer.init_with_size(block_size) |
| 15 |
|
| 16 |
# Set max_length, InitWithSize doesn't do this |
| 17 |
buffer.max_length = max_length |
| 18 |
ob.size = res |
| 19 |
ob.pos = 0 |
| 20 |
|
| 21 |
|
| 22 |
def _OutputBuffer_Grow(buffer, ob): |
| 23 |
res, ob.dst = buffer.grow(0) |
| 24 |
ob.size = res |
| 25 |
ob.pos = 0 |
| 26 |
|
| 27 |
|
| 28 |
def _OutputBuffer_Finish(buffer, ob): |
| 29 |
return buffer.finish(ob.size - ob.pos) |
| 30 |
|
| 31 |
|
| 32 |
def _OutputBuffer_ReachedMaxLength(buffer, ob): |
| 33 |
return buffer.allocated == buffer.max_length |