ping_iterator_get_context(3)

πŸ“¦
version 1.10.0 Β· 8 versions
, in alpine 3.24, epel 10, epel 9, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0

πŸ’– ping_iterator_get_context(3) β€” the liboping page where you stash ur lil per-host secrets πŸ’–

okay bestie so this is a liboping page, manual section 3, and it's about two lil functions that are basically a locker for your own stuff. like, liboping has all these host objects floating around and it's like "here, keep ur personal data in here, i won't look, i prommy" 🫢


🌸 NAME 🌸

ping_iterator_get_context, ping_iterator_set_context β€” store host-dependent data

it's giving "put ur stuff somewhere safe and get it back later", no cap πŸ’…


✨ SYNOPSIS ✨

#include <oping.h>

void *ping_iterator_get_context (pingobj_iter_t *iter);
void  ping_iterator_set_context (pingobj_iter_t *iter, void *context);

πŸ¦‹ DESCRIPTION πŸ¦‹

so ping_iterator_set_context is the one where you're like "hey liboping, hold this for me" β€” it lets you store host-specific data inside the liboping structures themselves. and then ping_iterator_get_context is the "okay give it back" function. you hand over a pointer, you get the pointer back. that's the whole vibe πŸ’–

and here's the iconic part: the data itself is never touched by liboping. not once. not ever. it just holds the pointer and minds its own business. main character energy fr fr ✨

⚠️ okay but listen β€” this is the part where you gotta pay attention, bestie. if you call ping_host_remove (peep ping_host_add(3)) or ping_destroy (peep ping_construct(3)) and the context is not NULL, liboping will just assume you know what you're doing and simply ignore the fact this might be a memory leak. it will not warn you. it will not clean up. it will not save you. it's your pointer, your problem πŸ’€ so like… handle ur own cleanup, okay? don't be out here leaking.

the iter argument is an iterator object as returned by ping_iterator_get(3) and ping_iterator_next. yk, the lil cursor that walks through ur hosts one at a time πŸšΆβ™€οΈ

the context argument of ping_iterator_set_context is a pointer to literally anything β€” anything at all β€” and it may be NULL. NULL is valid. NULL is fine. NULL is a mood 🌈


πŸŽ€ RETURN VALUE πŸŽ€

ping_iterator_get_context returns the same pointer you previously passed to ping_iterator_set_context β€” same one, untouched, exactly as you left it 🫢

or NULL if ping_iterator_set_context has never been called before. that's the "you never gave me anything so i got nothing for you" case. fair honestly πŸ’…


πŸ‘‘ SEE ALSO πŸ‘‘

go read those too, bestie, they're the whole friend group 🌸


πŸ’œ AUTHOR πŸ’œ

liboping is written by Florian "octo" Forster <ff at octo.it>. its homepage can be found at <http://noping.cc/> β€” iconic, legendary, we stan 🧚

Copyright (c) 2006-2017 by Florian "octo" Forster. yes that's a whole eleven years of copyright, respect the grind πŸ”₯


okay that's the page, bestie!! this is liboping 1.10.0, dated 2017-05-11, and honestly? storing pointers in iterators and pretending the leak isn't there is so real of it. go forth and ping_iterator_set_context responsibly, mwah πŸ’–βœ¨πŸŽ€