UDEV_NEW(3)
π
UDEV_NEW(3) β the udev_new girlies rise up β¨
okay so bestie, today we're talking about udev_new(3), which lives in the udev_new family of libudev functions, and honestly? it's giving "library card for the udev universe" π
πΈ NAME πΈ
udev_new, udev_ref, udev_unref β create, acquire and release a udev context object. that's the whole vibe: one makes it, one keeps it alive, one lets it go ππ
β¨ SYNOPSIS β¨
#include <libudev.h>
struct udev *udev_new(void);
struct udev *udev_ref(struct udev *udev);
struct udev *udev_unref(struct udev *udev);
like, look at her. three little functions. iconic behavior honestly π
π DESCRIPTION π
so udev_new() allocates a brand-new udev context object and returns a pointer to it. main character energy fr fr π
this object is opaque, and no cap β the caller must not access it through any means other than the functions provided by libudev. like, do not go poking around in there with your own little gremlin fingers, that's not the vibe π
initially, the reference count of the context is 1. you can acquire further references, and drop gained references, via udev_ref() and udev_unref(). and the moment the reference count hits 0? the context object is destroyed and freed. gone. poof. it's over π
π¦ RETURN VALUE π¦
- on success,
udev_new()returns a pointer to the allocated udev context β¨ - on failure,
NULLis returned π udev_ref()returns the argument that it was passed, unmodified β she gives it right back to you, no notes π«Άudev_unref()always returnsNULL. always. every time. periodt π
π HISTORY π
udev_new(), udev_ref(), and udev_unref() were added in version 221. vintage but still thriving, iykyk π
π SEE ALSO π
go read those next bestie, they're lowkey essential ππ
β οΈ reminder that this whole thing is a C API situation β if you call udev_unref() and then keep touching the context, that's undefined behaviour territory and we do not do that here. keep your refcounts balanced, queen π§
that's the page!! π this lil manual moment came to you courtesy of systemd 261.3 β mwah, go write some slay code bestie πβ¨π
π¦ where this page comes from
- ubuntu stonking: libudev-dev 261.3-0ubuntu3 Β· LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms