IEEE1284_REF(3)

πŸ“¦
version 0.2.11 Β· 7 versions
, in alpine 3.24, debian bookworm, debian trixie, opensuse-leap 16.0, ubuntu jammy, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ IEEE1284_REF(3) ✨

okay so bestie, this is a page from the Functions corner of the manual (section 3), and it's about ieee1284_ref and ieee1284_unref β€” the little duo that edits a port's reference count. yes it's short. yes it's important. let's get into it πŸ’…


🌸 NAME 🌸

ieee1284_ref, ieee1284_unref β€” the way you modify a port's reference count, fr fr


πŸŽ€ SYNOPSIS πŸŽ€

#include <ieee1284.h>

int ieee1284_ref(struct parport *port);

int ieee1284_unref(struct parport *port);

like, that's it. two functions. one header. iconic honestly πŸ¦‹


πŸ’– DESCRIPTION πŸ’–

so here's the vibe: if you wanna free the port list you got from ieee1284_find_ports, but you're planning to open one of those ports later on, you gotta protect it from getting destroyed when ieee1284_free_ports does its thing. 😭

and how do you do that? every port has a reference count, and you use ieee1284_ref to increment it, and ieee1284_unref to decrement it. that's the whole mechanic. lowkey elegant.

⚠️ okay this part is the important part, don't skip it ⚠️

if you use ieee1284_ref at any stage, you must later call ieee1284_unref to relinquish the extra reference. if you don't do this, the resources associated with the port will not be cleaned up. like, they just sit there. leaking. sad. πŸ’€

and the flip side, bestie, is equally serious: if you have not previously used ieee1284_ref on a port, you must not use ieee1284_unref on it. periodt. 🫢


🌈 RETURN VALUE 🌈

both of these return the number of references held after the increment or decrement. so like, the post-math count. cute. ⭐


πŸ‘‘ SEE ALSO πŸ‘‘

go read that one next, iykyk 🧚


πŸ’œ AUTHOR πŸ’œ

Tim Waugh <twaugh@redhat.com>

  • Author.

(hi tim, king πŸ‘‘)


Copyright Β© 2001-2003 Tim Waugh


and that's the whole page babes πŸ’… the source/version tag on this one is IEEE1284_REF(3), dated 09/18/2007 β€” yes, 2007, she's vintage and she's still serving. mwah, go refcount responsibly πŸŒΈβœ¨πŸ¦‹