diff options
author | lloyd <[email protected]> | 2010-09-13 15:54:50 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-09-13 15:54:50 +0000 |
commit | 36bfef27271eadffefbc6891a9d7fa7eed7b1e10 (patch) | |
tree | 81fe9b37bb580cedba5bb25ac04dfecdd36b18de /src/alloc | |
parent | 4a7e9edcc92b08a285ea24549fd8c813d10b63b9 (diff) |
More vector->pointer conversion removals.
Add RandomNumberGenerator::random_vec, which takes an length n and
returns a new SecureVector with randomized contents of that size. This
nicely covers most of the cases where randomize was being called on a
vector, and is a little cleaner in the code as well, instead of
vec.resize(length);
rng.randomize(&vec[0], vec.size());
we just write
vec = rng.random_vec(length);
Diffstat (limited to 'src/alloc')
-rw-r--r-- | src/alloc/secmem.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/alloc/secmem.h b/src/alloc/secmem.h index dc5e90b79..c87035a1e 100644 --- a/src/alloc/secmem.h +++ b/src/alloc/secmem.h @@ -34,6 +34,7 @@ class MemoryRegion */ bool empty() const { return (used == 0); } +#if 1 /** * Get a pointer to the first element in the buffer. * @return pointer to the first element in the buffer @@ -45,6 +46,12 @@ class MemoryRegion * @return constant pointer to the first element in the buffer */ operator const T* () const { return buf; } +#else + + T& operator[](u32bit n) { return buf[n]; } + const T& operator[](u32bit n) const { return buf[n]; } + +#endif /** * Get a pointer to the first element in the buffer. |