Skip to content

Commit

Permalink
fix: zbuf init code
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-roland committed Oct 17, 2024
1 parent b0589d4 commit 1776867
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/protocol/iobuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,16 @@ _z_iosli_t *_z_iosli_clone(const _z_iosli_t *src) {

/*------------------ ZBuf ------------------*/
_z_zbuf_t _z_zbuf_make(size_t capacity) {
_z_zbuf_t zbf;
_z_zbuf_t zbf = {0};
zbf._ios = _z_iosli_make(capacity);
if (_z_zbuf_capacity(&zbf) == 0) {
return zbf;
}
_z_slice_t s = _z_slice_from_buf_custom_deleter(zbf._ios._buf, zbf._ios._capacity, _z_delete_context_default());
zbf._slice = _z_slice_simple_rc_new_from_val(&s);
if (_Z_RC_IS_NULL(&zbf._slice)) {
_Z_ERROR("slice rc creation failed");
_z_zbuf_clear(&zbf);
_z_iosli_clear(&zbf._ios);
}
zbf._ios._is_alloc = false;
return zbf;
Expand Down

0 comments on commit 1776867

Please sign in to comment.