NNG_MTX_ALLOC(3supp)

πŸ“¦ version 1.11, in alpine 3.24

NNG_MTX_ALLOC(3supp) β€” allocate mutex ✨

okay so this one is straight out of the NNG Reference Manual, and today’s main character is nng_mtx_alloc (3supp). bestie, we’re allocating a mutex. it’s giving tiny lock-shaped legend πŸ’…


🌸 NAME 🌸

nng_mtx_alloc β€” allocate mutex πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <nng/nng.h>

typedef struct nng_mtx nng_mtx;

int nng_mtx_alloc(nng_mtx **mtxp);

✨ DESCRIPTION ✨

so the nng_mtx_alloc() function allocates a mutex and hands it back to you in mtxp. iconic behavior, no cap 🫢

the mutex objects made by this function are suitable only for simple lock and unlock operations, and they are not recursive. like, do not expect them to re-enter themselves, because they will not. every effort has been made to use light-weight underlying primitives when available β€” lowkey efficient, highkey slay ⚑

mutex (mutual exclusion) objects can be thought of as binary semaphores, where only a single thread of execution is permitted to acquire the semaphore. one thread. that’s the vibe. πŸ‘‘

and furthermore: a mutex can only be unlocked by the thread that locked it. periodt. πŸ”’


πŸ’– RETURN VALUES πŸ’–

this function returns 0 on success, and non-zero otherwise. that’s it, that’s the whole return-value moment ✨


πŸŽ€ ERRORS πŸŽ€

  • NNG_ENOMEM β€” insufficient free memory exists. translation: not enough free memory to make it happen πŸ˜­πŸ’€

🌈 SEE ALSO 🌈


later bestie πŸ’– this page is from the NNG Reference Manual, dated 2026-01-13, and the page tag is NNG_MTX_ALLOC(3supp) β€” go forth and lock responsibly πŸ§šβ€β™€οΈπŸŒΈ

πŸ“¦ where this page comes from