From e201c88a7931bc892c7d608ee9130ceb7c0f2fef Mon Sep 17 00:00:00 2001 From: lloyd Date: Fri, 3 Sep 2010 13:19:28 +0000 Subject: Add a simple function to MemoryRegion to truncate to a specified size. Required by the hex decoder. --- src/alloc/secmem.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/alloc') 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 @@ -161,6 +161,16 @@ class MemoryRegion void append(const MemoryRegion& other) { 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. */ -- cgit v1.2.3