aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc
diff options
context:
space:
mode:
Diffstat (limited to 'src/alloc')
-rw-r--r--src/alloc/secmem.h52
1 files changed, 34 insertions, 18 deletions
diff --git a/src/alloc/secmem.h b/src/alloc/secmem.h
index cbc4354ad..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);
}
@@ -141,14 +144,6 @@ class MemoryRegion
}
/**
- * 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); }
-
- /**
* Append a single element.
* @param x the element to append
*/
@@ -189,7 +184,8 @@ class MemoryRegion
buf = 0;
used = allocated = 0;
alloc = other.alloc;
- set(other.buf, other.used);
+ resize(other.size());
+ copy(&other[0], other.size());
}
/**
@@ -285,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);
}
@@ -302,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());
+ }
};
/**
@@ -323,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.
@@ -344,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);
}
/**
@@ -355,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());
}
};