diff options
| author | Tyge Løvset <[email protected]> | 2021-09-08 09:05:16 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2021-09-08 09:05:16 +0200 |
| commit | 10e8e2017c8193b784f30a2aeb625f6eb0d3e965 (patch) | |
| tree | 2ba2d17b36bd12c38afd675bdb8db9565cc4631f /include/stc/cstack.h | |
| parent | f16e08017abfc44864b37a42c42951f0fd885f5f (diff) | |
| download | STC-modified-10e8e2017c8193b784f30a2aeb625f6eb0d3e965.tar.gz STC-modified-10e8e2017c8193b784f30a2aeb625f6eb0d3e965.zip | |
Added init_with_capacity().
Diffstat (limited to 'include/stc/cstack.h')
| -rw-r--r-- | include/stc/cstack.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/include/stc/cstack.h b/include/stc/cstack.h index f68a01d7..448b6c2f 100644 --- a/include/stc/cstack.h +++ b/include/stc/cstack.h @@ -39,6 +39,11 @@ typedef i_valraw cx_rawvalue_t; STC_INLINE Self cx_memb(_init)(void)
{ return (Self){0, 0, 0}; }
+STC_INLINE Self cx_memb(_init_with_capacity)(size_t cap) {
+ Self out = {(cx_value_t *) c_malloc(cap*sizeof(cx_value_t)), 0, cap};
+ return out;
+}
+
STC_INLINE void cx_memb(_clear)(Self* self) {
size_t i = self->size; self->size = 0;
while (i--) i_valdel(&self->data[i]);
|
