GEARMAN_WORKER_CLONE(3)

πŸ¦‹ GEARMAN_WORKER_CLONE πŸ¦‹

okay so bestie, you're looking at GEARMAN_WORKER_CLONE(3) β€” that's section 3 of the Gearmand manual, the library-functions section. This page is literally The Clone Page πŸ’… but it also covers the create/free triplets because they're a package deal. Let's go.


🌸 NAME 🌸

gearman_worker_clone β€” Gearmand Documentation, http://gearman.info/


✨ SYNOPSIS ✨

#include <libgearman/gearman.h>

gearman_worker_st <#c.gearman_worker_st>
*gearman_worker_create(gearman_worker_st <#c.gearman_worker_st> *client)

gearman_worker_st <#c.gearman_worker_st>
*gearman_worker_clone(gearman_worker_st <#c.gearman_worker_st> *client,
const gearman_worker_st <#c.gearman_worker_st> *from)

void gearman_worker_free(gearman_worker_st <#c.gearman_worker_st>
*client)

Link with -lgearman

you already know this but: link the library or the linker will simply not speak to you πŸ™ˆ

πŸ’… DESCRIPTION πŸ’…

gearman_worker_create() is the function you use to create a gearman_worker_st structure, and once it exists, all the other libgearman(3) client functions use it to talk to the server. You've got two options going in: hand it a statically declared gearman_worker_st, or hand it a NULL. Pass in NULL and a structure gets allocated for you, king behavior. πŸ‘‘

gearman_worker_clone() is giving sibling energy to gearman_worker_create() β€” it does the same kind of thing, except on top of that it copies the defaults and the list of servers over from the source gearman_worker_st. And if you pass a null as the argument for the source you're cloning from? That's literally identical to just calling gearman_worker_create(). And if the destination argument is NULL, a gearman_worker_st gets allocated for you. No cap.

Now, memory. To clean up everything hanging off a gearman_worker_st structure, you pass it to gearman_worker_free() once you're done with it. And listen β€” gearman_worker_free is the only way to make sure all that memory is actually deallocated when you finish using the structure. Not optional, bestie. Skipping it is how you leak. 😭

One more tea: you may wish to avoid using gearman_worker_create() or gearman_worker_clone() with a stack based allocation, i.e. that first parameter. The most common issues related to ABI safety involve heap allocated structures. So like, heap is the vibe, stack is where the jump scares live. πŸ’€

also lol, the OG page literally types gearman_worker_create) with a stray closing paren in the middle of a sentence. We do not fix the ancestors, we simply honor them. πŸ™

πŸŽ€ RETURN VALUE πŸŽ€

  • gearman_worker_create() β€” returns a pointer to the gearman_worker_st that was created (or initialized). If the allocation fails, it returns NULL.
  • gearman_worker_clone() β€” returns a pointer to the gearman_worker_st that was created (or initialized). If the allocation fails, it returns NULL.

so basically: pointer = slay, NULL = check your allocation, bestie. ✨


🌈 HOME 🌈

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

See also:


🌟 Author 🌟

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


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


and that's the page!! 🫢 source/version is 1.1.21+ds, it's dated Feb 04, 2026, and it belongs to GEARMAN_WORKER_CLONE(3). go forth and clone responsibly, bestie πŸŽ€πŸ§šπŸ’–

πŸ“¦ where this page comes from