diff options
| author | Tyge Løvset <[email protected]> | 2021-10-06 16:08:08 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2021-10-06 16:08:08 +0200 |
| commit | 435fd25e5c74aea72eb20f4007977183cdbe0919 (patch) | |
| tree | 58606c15052b37d27858ea6f707df8b2edf34a49 /include/stc/cstack.h | |
| parent | 0fa5220d8d7cddbb668d02045ebd36709ba0bc6f (diff) | |
| download | STC-modified-435fd25e5c74aea72eb20f4007977183cdbe0919.tar.gz STC-modified-435fd25e5c74aea72eb20f4007977183cdbe0919.zip | |
Some while to for changed. Return value for cstack_X_push/emplace. Docs updated.
Diffstat (limited to 'include/stc/cstack.h')
| -rw-r--r-- | include/stc/cstack.h | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/include/stc/cstack.h b/include/stc/cstack.h index 7bc0f3fb..00d99fa1 100644 --- a/include/stc/cstack.h +++ b/include/stc/cstack.h @@ -83,13 +83,14 @@ STC_INLINE void cx_memb(_reserve)(Self* self, size_t n) { STC_INLINE void cx_memb(_shrink_to_fit)(Self* self)
{ cx_memb(_reserve)(self, self->size); }
-STC_INLINE void cx_memb(_push)(Self* self, cx_value_t val) {
+STC_INLINE cx_value_t* cx_memb(_push)(Self* self, cx_value_t val) {
if (self->size == self->capacity) cx_memb(_reserve)(self, self->size*3/2 + 4);
- self->data[ self->size++ ] = val;
+ cx_value_t* vp = self->data + self->size++;
+ *vp = val; return vp;
}
-STC_INLINE void cx_memb(_emplace)(Self* self, cx_rawvalue_t raw)
- { cx_memb(_push)(self, i_valfrom(raw)); }
+STC_INLINE cx_value_t* cx_memb(_emplace)(Self* self, cx_rawvalue_t raw)
+ { return cx_memb(_push)(self, i_valfrom(raw)); }
STC_INLINE Self cx_memb(_clone)(Self v) {
Self out = {(cx_value_t *) c_malloc(v.size*sizeof(cx_value_t)), v.size, v.size};
|
