summaryrefslogtreecommitdiffstats
path: root/src/base/auto_mem.hh
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/base/auto_mem.hh12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/base/auto_mem.hh b/src/base/auto_mem.hh
index e6b456c..b404a1b 100644
--- a/src/base/auto_mem.hh
+++ b/src/base/auto_mem.hh
@@ -66,6 +66,16 @@ public:
return retval;
}
+ static auto_mem calloc(size_t count)
+ {
+ return auto_mem(static_cast<T*>(::calloc(count, sizeof(T))));
+ }
+
+ static auto_mem malloc(size_t sz)
+ {
+ return auto_mem(static_cast<T*>(::malloc(sz)));
+ }
+
explicit auto_mem(T* ptr = nullptr)
: am_ptr(ptr), am_free_func(default_free)
{
@@ -241,6 +251,8 @@ public:
const char* begin() const { return this->ab_buffer; }
+ char* next_available() { return &this->ab_buffer[this->ab_size]; }
+
auto_buffer& push_back(char ch)
{
if (this->ab_size == this->ab_capacity) {