aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc/secmem.h
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-11-02 18:42:37 +0000
committerlloyd <[email protected]>2010-11-02 18:42:37 +0000
commit66ff3ef44894c159c1c51cd282b550ea3826a007 (patch)
tree22a9abf63333963db637bc6923066117fb6277b0 /src/alloc/secmem.h
parent7975f12f190df412105e0cc1db56298910956ca0 (diff)
Remove MemoryRegion::set entirely
Diffstat (limited to 'src/alloc/secmem.h')
-rw-r--r--src/alloc/secmem.h54
1 files changed, 34 insertions, 20 deletions
diff --git a/src/alloc/secmem.h b/src/alloc/secmem.h
index 5261724ae..b06be0d55 100644
--- a/src/alloc/secmem.h
+++ b/src/alloc/secmem.h
@@ -110,7 +110,10 @@ class MemoryRegion
MemoryRegion<T>& operator=(const MemoryRegion<T>& other)
{
if(this != &other)
- set(&other[0], other.size());
+ {
+ this->resize(other.size());
+ this->copy(&other[0], other.size());
+ }
return (*this);
}
@@ -135,12 +138,10 @@ class MemoryRegion
* @param in the array to copy the contents from
* @param n the length of in
*/
-#if 1
void copy(size_t off, const T in[], size_t n)
{
copy_mem(buf + off, in, std::min(n, size() - off));
}
-#endif
/**
* Append a single element.
@@ -183,18 +184,11 @@ class MemoryRegion
buf = 0;
used = allocated = 0;
alloc = other.alloc;
- set(other.buf, other.used);
+ resize(other.size());
+ copy(&other[0], other.size());
}
/**
- * Set the contents of this according to the argument. The size of
- * this is increased if necessary.
- * @param in the array of objects of type T to copy the contents from
- * @param n the size of array in
- */
- void set(const T in[], size_t n) { resize(n); copy(in, n); }
-
- /**
* @param locking should we use a locking allocator
* @param length the initial length to use
*/
@@ -287,7 +281,10 @@ class MemoryVector : public MemoryRegion<T>
MemoryVector<T>& operator=(const MemoryRegion<T>& in)
{
if(this != &in)
- this->set(&in[0], in.size());
+ {
+ this->resize(in.size());
+ this->copy(&in[0], in.size());
+ }
return (*this);
}
@@ -304,13 +301,21 @@ class MemoryVector : public MemoryRegion<T>
* @param n the size of the arry in
*/
MemoryVector(const T in[], size_t n)
- { this->init(false); this->set(in, n); }
+ {
+ this->init(false);
+ this->resize(n);
+ this->copy(in, n);
+ }
/**
* Copy constructor.
*/
MemoryVector(const MemoryRegion<T>& in)
- { this->init(false); this->set(&in[0], in.size()); }
+ {
+ this->init(false);
+ this->resize(in.size());
+ this->copy(&in[0], in.size());
+ }
};
/**
@@ -325,11 +330,18 @@ class SecureVector : public MemoryRegion<T>
public:
/**
* Copy the contents of another buffer into this buffer.
- * @param in the buffer to copy the contents from
+ * @param other the buffer to copy the contents from
* @return reference to *this
*/
- SecureVector<T>& operator=(const MemoryRegion<T>& in)
- { if(this != &in) this->set(&in[0], in.size()); return (*this); }
+ SecureVector<T>& operator=(const MemoryRegion<T>& other)
+ {
+ if(this != &other)
+ {
+ this->resize(other.size());
+ this->copy(&other[0], other.size());
+ }
+ return (*this);
+ }
/**
* Create a buffer of the specified length.
@@ -346,7 +358,8 @@ class SecureVector : public MemoryRegion<T>
SecureVector(const T in[], size_t n)
{
this->init(true);
- this->set(&in[0], n);
+ this->resize(n);
+ this->copy(&in[0], n);
}
/**
@@ -357,7 +370,8 @@ class SecureVector : public MemoryRegion<T>
SecureVector(const MemoryRegion<T>& in)
{
this->init(true);
- this->set(&in[0], in.size());
+ this->resize(in.size());
+ this->copy(&in[0], in.size());
}
};