resize_to_fit(9)
π resize_to_fit(9) β the Kernel API Manual glow-up π
okay bestie, so this is resize_to_fit from the Kernel API Manual, and it's lowkey the most helpful little function ever. like, it does exactly what it says on the tin: it resizes a buffer so it fits the amount of data you actually need. no drama, no guessing, just vibes and vmalloc. π
β¨ SYNOPSIS β¨
int resize_to_fit (char **buf , size_t *size , size_t desired_size );
that's the whole signature, bestie β memorize it, it's giving main character energy π«Ά
πΈ ARGUMENTS πΈ
bufβ a double pointer to your destination buffer. yeah, double pointer β two stars, two slays ββsizeβ a pointer to the size container. it's literally holding the size for you πdesired_sizeβ the size the buffer must contain. this is the goal, the dream, the target π―
π¦ DESCRIPTION π¦
so here's the tea: it returns 0 on success, or an error code on failure. that's it, that's the contract. π€
on success, the size of the buffer is at least desired_size β so it might be bigger, it's not gonna be smaller, we don't do that here. β¨
and the important part, no cap: the buffer is allocated via vmalloc and must be freed with vfree.
π¨ bestie please do not forget thevfree.vmallocandvfreeare a matched set, like me and iced coffee. if you free it wrong that's a whole situation π
π§ SEE ALSO π§
the kernel file lives at ./drivers/accel/habanalabs/common/state_dump.c β that's where the magic happens, iykyk π
and here's the whole friend group, all the sibling functions pulling up to the function party π₯
hl_format_as_binary(9)hl_snprintf_resize(9)hl_sync_engine_to_string(9)hl_print_resize_sync_engine(9)hl_state_dump_get_sync_name(9)hl_state_dump_get_monitor_name(9)hl_state_dump_free_sync_to_engine_map(9)hl_state_dump_get_sync_to_engine(9)hl_state_dump_read_sync_objects(9)hl_state_dump_free_sync_objects(9)hl_state_dump_print_syncs_single_block(9)hl_state_dump_print_syncs(9)hl_state_dump_alloc_read_sm_block_monitors(9)hl_state_dump_free_monitors(9)hl_state_dump_print_monitors_single_block(9)hl_state_dump_print_monitors(9)hl_state_dump_print_engine_fences(9)hl_state_dump_print_fences(9)hl_state_dump(9)
like, the whole hl_state_dump cinematic universe is right there. go read them all, you're welcome π
and that's the page! brought to you from ./drivers/accel/habanalabs/common, dated October 2026, and it's resize_to_fit(9) forever and always. slay, go free your buffers π
β¨π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms