summaryrefslogtreecommitdiffstats
path: root/src/base/auto_mem.hh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-07 04:48:35 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-07 04:48:35 +0000
commit207df6fc406e81bfeebdff7f404bd242ff3f099f (patch)
treea1a796b056909dd0a04ffec163db9363a8757808 /src/base/auto_mem.hh
parentReleasing progress-linux version 0.11.2-1~progress7.99u1. (diff)
downloadlnav-207df6fc406e81bfeebdff7f404bd242ff3f099f.tar.xz
lnav-207df6fc406e81bfeebdff7f404bd242ff3f099f.zip
Merging upstream version 0.12.2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
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) {