SAM_D...TSIZE(3)

πŸ’– SAM_D...TSIZE(3) πŸ’–

okay so bestie, this is a page from the Corosync Cluster Engine Programmer's Manual β€” yes the section-3 kind, the "I'm a C function" kind. Buckle up, it's short but it's iconic πŸ’…


✨ NAME ✨

sam_data_getsize β€” bestie, it returns the size of your stored data, in bytes πŸ¦‹


🌸 SYNOPSIS 🌸

#include <corosync/sam.h>

cs_error_t sam_data_getsize (size_t *size);

like. that's it. that's the whole vibe. one include, one function call, and you're cooking πŸŽ€


🫢 DESCRIPTION 🫢

so the sam_data_getsize function is used to return the size of stored data. Size is returned in bytes. ✨

If user data is NULL, zero is returned. no drama, no crash, just a lil zero. πŸ’€

and here's the part that actually matters, the main character energy of this whole manpage: this function is intended to be used before the sam_data_restore(3) call, so you can properly allocate a buffer for the restored data. like, you gotta know how big the thing is before you make room for the thing, yk? it's giving "measure twice, cut once" fr fr βœ‚οΈ


⭐ RETURN VALUE ⭐

This call returns CS_OK if it's successful πŸŽ‰ β€” otherwise an error is returned 😭


πŸ’€ ERRORS πŸ’€

here's where things go wrong, and ngl you're gonna want to read this part:

  • CS_ERR_BAD_HANDLE β€” the component was not initialized by calling sam_initialize(3), or it was finalized. like bestie, you can't use a thing that was never set up, or a thing you already shut down πŸ™ˆ
  • CS_ERR_INVALID_PARAM β€” the size parameter is NULL. yeah. you handed it nothing. it's not doing that. πŸ’…

πŸ‘‘ SEE ALSO πŸ‘‘

go check out these besties, they're all part of the same friend group:

and here's the whole squad of error codes, in case you were wondering what the rest of them mean πŸ‘‡

  • CS_ERR_TRY_AGAIN β€” Resource temporarily unavailable
  • CS_ERR_INVALID_PARAM β€” Invalid argument
  • CS_ERR_ACCESS β€” Permission denied
  • CS_ERR_LIBRARY β€” The connection failed
  • CS_ERR_INTERRUPT β€” System call interrupted by a signal
  • CS_ERR_NOT_SUPPORTED β€” The requested protocol/functionality not supported
  • CS_ERR_MESSAGE_ERROR β€” Incorrect auth message received
  • CS_ERR_NO_MEMORY β€” Not enough memory to complete the requested task

and that's the whole page, bestie, no notes. this lil gem lives in the corosync Man Page from 04/15/2010, filed under SAM_D...TSIZE(3) πŸ¦‹βœ¨ go allocate that buffer correctly, you absolute icon πŸ’–πŸ‘‘

πŸ“¦ where this page comes from