diff options
| author | Tyge Løvset <[email protected]> | 2022-12-30 18:45:56 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-12-30 18:45:56 +0100 |
| commit | e124d8c7377de1dfce45790a196312596f6b9be5 (patch) | |
| tree | 528ebcc735cdb5d958b987c886d369bc02a11320 /include/stc/cbox.h | |
| parent | 4f0f45422fb58e9b134445ad6a4ea96d806214e8 (diff) | |
| download | STC-modified-e124d8c7377de1dfce45790a196312596f6b9be5.tar.gz STC-modified-e124d8c7377de1dfce45790a196312596f6b9be5.zip | |
Fixed carc and cbox docs. Added cbox_X_assign() : transfer ownership between cboxes.
Diffstat (limited to 'include/stc/cbox.h')
| -rw-r--r-- | include/stc/cbox.h | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/include/stc/cbox.h b/include/stc/cbox.h index a0966fcc..b8a61375 100644 --- a/include/stc/cbox.h +++ b/include/stc/cbox.h @@ -142,10 +142,18 @@ STC_INLINE _cx_self _cx_memb(_from)(_cx_value val) } #endif // !i_no_clone -STC_INLINE void _cx_memb(_take)(_cx_self* self, _cx_self other) { - if (other.get != self->get) +STC_INLINE void _cx_memb(_take)(_cx_self* self, _cx_self unowned) { + if (unowned.get != self->get) _cx_memb(_drop)(self); - *self = other; + *self = unowned; +} +/* transfer ownership; set dying to NULL */ +STC_INLINE void _cx_memb(_assign)(_cx_self* self, _cx_self* dying) { + if (dying->get == self->get) + return; + _cx_memb(_drop)(self); + *self = *dying; + dying->get = NULL; } #ifndef i_no_cmp |
