GEARMAN_CLIENT_CREATE(3)

πŸ’– GEARMAN_CLIENT_CREATE πŸ’–

okay bestie, pull up a chair 🫢 this is the libgearman manual, section 3, and today's main character is gearman_client_create β€” the one that makes your client struct exist in the first place.


✨ NAME ✨

gearman_client_create β€” Gearmand Documentation, <http://gearman.info/>

Just to be clear: that's the official Gearmand documentation link, not me being cute. (I'm also being cute. Both things are true.)


πŸŽ€ SYNOPSIS πŸŽ€

#include <libgearman/gearman.h>

gearman_client_st <#c.gearman_client_st>
*gearman_client_create(gearman_client_st <#c.gearman_client_st> *client)

gearman_client_st <#c.gearman_client_st>
*gearman_client_clone(gearman_client_st <#c.gearman_client_st> *client,
const gearman_client_st <#c.gearman_client_st> *from)

void gearman_client_free(gearman_client_st <#c.gearman_client_st>
*client)

Link with -lgearman

bestie the <#c.gearman_client_st> bits are literally just how the docs mark up that cross-reference to the gearman_client_st type β€” do not type those into your compiler or she WILL yell at you 😭

πŸ¦‹ DESCRIPTION πŸ¦‹

gearman_client_create() is your origin story, fr fr πŸ’… it creates a c:type:gearman_client_st structure that every other libgearman client function will use to talk to the server. So like, nothing else works until you've done this. Main character energy only.

You've got two ways to do it, and you must pick one:

  • hand it a statically declared gearman_client_st <#c.gearman_client_st> that you already have lying around, or
  • hand it a NULL.

If you pass in a NULL, the structure gets allocated for you. ✨

gearman_client_clone() is giving very much "create but with receipts" πŸ“‹ it copies the defaults and the list of servers from the source gearman_client_st <#c.gearman_client_st>. Two fun edge cases for you:

  • If you pass a NULL as the argument for the source to clone, it's exactly the same as a call to gearman_client_create.
  • If the destination argument is NULL, a gearman_client_st <#c.gearman_client_st> will be allocated for you.

And then when you're done slaying? To clean up the memory associated with a gearman_client_st <#c.gearman_client_st> structure, you should pass it to gearman_client_free once you're finished with it. Not optional, babes β€” gearman_client_free() is the only way to make sure all memory is deallocated when you finish using the structure. πŸ‘‘

🚨 Warning 🚨

You may wish to avoid using gearman_client_create() or gearman_client_clone() with a stack based allocation, i.e. the first parameter. The most common issues related to ABI safety involve stack allocated structures.

ngl, this one's the realest part of the whole page β€” stack allocation here is the vibe killer πŸ’€ ABI safety issues live there. Heed it.


🌈 RETURN VALUE 🌈

  • gearman_client_create returns a pointer to the gearman_client_st that was created (or initialized). On an allocation failure, it returns NULL.
  • gearman_client_clone returns a pointer to the gearman_client_st that was created (or initialized). On an allocation failure, it returns NULL.

So: pointer = slay, NULL = allocation said no πŸ™ˆ


🏠 HOME 🏠

To find out more information please check: <http://gearman.info/>

See also:

gearmand(8) libgearman(3) gearman_strerror(3) gearman_client_st(3)


Author

Data Differential <http://www.datadifferential.com/>

Copyright

2011-2014, Data Differential, <http://www.datadifferential.com/>


and that's the tea, bestie πŸ“ this edition is 1.1.21+ds, dated Feb 04, 2026, and it goes by GEARMAN_CLIENT_CREATE(3) around these parts πŸŽ€ go forth and gearman_client_free your stuff, i'm obsessed with you πŸ’œ

πŸ“¦ where this page comes from