diff options
author | lloyd <[email protected]> | 2010-09-03 13:19:28 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-09-03 13:19:28 +0000 |
commit | e201c88a7931bc892c7d608ee9130ceb7c0f2fef (patch) | |
tree | 54556a7185505459bb8f09d1bb15cac1614ddc7b /src | |
parent | 449c9b9467c3e8dc08015094100162aea209623e (diff) |
Add a simple function to MemoryRegion to truncate to a specified size.
Required by the hex decoder.
Diffstat (limited to 'src')
-rw-r--r-- | src/alloc/secmem.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/alloc/secmem.h b/src/alloc/secmem.h index 13d2bfdce..f14e2a9db 100644 --- a/src/alloc/secmem.h +++ b/src/alloc/secmem.h @@ -162,6 +162,16 @@ class MemoryRegion { append(other.begin(), other.size()); } /** + * Truncate the buffer to at most n elements + * @param n the length of the resulting buffer + */ + void truncate(u32bit n) + { + if(n < used) + used = n; + } + + /** * Zeroise the bytes of this buffer. The length remains unchanged. */ void clear() { clear_mem(buf, allocated); } |