Skip to content

Commit e8c9b36

Browse files
committed
ft_bytes_alloc/ft_bytes_free
1 parent 8dc07e9 commit e8c9b36

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/fu_util/fo_obj.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,7 @@ fobj_error_kind(RT);
527527
fobj_error_kind(SysErr);
528528

529529
fobj_error_object_key(cause);
530+
fobj_error_cstr_key(causeStr);
530531
fobj_error_int_key(errNo);
531532
fobj_error_cstr_key(errNoStr);
532533
#define fobj_errno_keys(errno) (errNo, errno), (errNoStr, ft_strerror(errno))

src/fu_util/ft_util.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,15 @@ ft_inline ft_bytes_t ft_bytes(void* ptr, size_t len) {
314314
return (ft_bytes_t){.ptr = (char*)ptr, .len = len};
315315
}
316316

317+
ft_inline ft_bytes_t ft_bytes_alloc(size_t sz) {
318+
return ft_bytes(ft_malloc(sz), sz);
319+
}
320+
321+
ft_inline void ft_bytes_free(ft_bytes_t* bytes) {
322+
ft_free(bytes->ptr);
323+
*bytes = ft_bytes(NULL, 0);
324+
}
325+
317326
ft_inline void ft_bytes_consume(ft_bytes_t *bytes, size_t cut);
318327
ft_inline void ft_bytes_move(ft_bytes_t *dest, ft_bytes_t *src);
319328

0 commit comments

Comments
 (0)