hlist_add_head(9)
π hlist_add_head(9) π
okay so this is a page from the Kernel API Manual, and bestie, it's a short one but it's literally iconic. sit down, grab a boba, let's go β¨
πΈ NAME πΈ
hlist_add_head β add a new entry at the beginning of the hlist π
like, the very beginning. front of the line. main character spot. no cap π
β¨ SYNOPSIS β¨
void hlist_add_head (struct hlist_node *n , struct hlist_head *h );
that's it. two pointers, zero drama, returns nothing (void bestie, it's giving "I do this for the plot, not for the return value") π¦
π«Ά ARGUMENTS π«Ά
nβ the new entry you're adding. your little guy. your blorbo. the fresh node going in πhβ the hlist head you're adding it after. the vibe anchor. the boss of the list π
π₯ DESCRIPTION π₯
Insert a new entry after the specified head. periodt. that's the whole thing.
and the best part? this is good for implementing stacks. the way that a stack is literally just "newest thing on top" and this function is literally "newest thing at the front" β the synergy is unmatched, I'm obsessed ππ₯ LIFO girlies stay winning fr fr.
ngl it's a tiny function but it's carrying entire data structures on its back. respect the hustle π
π SEE ALSO π
Kernel file ./scripts/include/list.h β that's where the magic lives, go read it, iykyk πβ¨
and then the whole friend group:
container_of(9)INIT_LIST_HEAD(9)list_add(9)list_add_tail(9)list_del(9)list_replace(9)list_replace_init(9)list_move(9)list_move_tail(9)list_is_first(9)list_is_last(9)list_is_head(9)list_empty(9)list_entry(9)list_first_entry(9)list_last_entry(9)list_next_entry(9)list_prev_entry(9)list_entry_is_head(9)list_for_each_entry(9)list_for_each_entry_reverse(9)list_for_each_entry_safe(9)hlist_unhashed(9)hlist_del(9)hlist_del_init(9)hlist_for_each_entry(9)hlist_for_each_entry_safe(9)
anyway that's the page π this came out of ./scripts/include, dated October 2026, and honestly? slay. go add something to the head of a list, you've earned it πβ¨π¦
π¦ 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