dictSearch(3)

πŸ’– dictSearch(3) πŸ’–

okay so bestie, welcome to dictSearch(3) β€” the little function from util/dict.h that goes hunting through a dictionary for your fave value and hands it back to you. it's giving "personal shopper but for data" ✨ let's get into it.


🌸 NAME 🌸

dictSearch β€” search for value in dictionary. no cap, that's the whole job description. πŸ’…


✨ SYNOPSIS ✨

#include <util/dict.h>

void *dictSearch(dictCtx dict, const char *id, void **plock);

like… three args, one pointer back, and a whole lot of main character energy. 🫢


πŸŽ€ ARGUMENTS πŸŽ€

  • dict β€” the dictionary you're searching in. your search zone. your kingdom. πŸ‘‘
  • id β€” the identifier of the item you wanna find. it's literally the name tag at the party. 🏷️
  • plock β€” place for the value lock (or NULL if you're not about that lock life). πŸ™ˆ

πŸ¦‹ DESCRIPTION πŸ¦‹

so what it does: it searches for <id> in <dict>, and returns the value if it found it, or NULL if it didn't. that's it, that's the vibe. πŸ”

and here's the spicy part β€” if <plock> is non-NULL, then the lock returned in <plock> will be associated with the returned value. the way that works: until this lock is passed to dictReleaseLock(), the value will not be passed to the dictCleanupFunc callback (see dictCleanup()). so like, hold onto that lock and you're basically protecting your fave from getting swept up. πŸ’–

MT-Level: Safe if <dict> is thread-safe. periodt. 🧡


⭐ RETURN VALUE ⭐

  • plock β€” set to the value lock. yeah bestie, it writes back into your pointer. 😭

🌈 SEE ALSO 🌈

like a whole friend group fr fr, go say hi. 🫢✨


ClearSilver Β· 12 July 2007 β€” yeah this page has been iconic since way back, and it's still serving. stay hydrated, lock your values, and go search something. πŸ’…πŸŽ€πŸ¦‹