PX_GET_DATA_BYTES(3)

πŸ’– PX_get_data_bytes(3) πŸ’–

okay bestie, so this one lives in the Library Functions Manual, section 3 β€” that's the "C library calls" section, iykyk. Grab a boba, we're doing a deep dive. πŸ§‹βœ¨


🌸 NAME 🌸

PX_get_data_bytes β€” snag the value out of a bytes data field, bestie πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <paradox.h>

int PX_get_data_bytes(pxdoc_t *pxdoc, char *data, int len, char **value)

✨ DESCRIPTION ✨

So here's the vibe: this function reads a data field that's literally just an array of bytes, copies it into a fresh chunk of memory, and hands you back a pointer to that chunk in value. πŸŽ€

🫢 Heads up though β€” the memory is allocated by this function, which means you, the calling application, have to free it. She's not gonna clean up after herself, that's your job now. πŸ’€

And like, genuinely, please use this function instead of poking at the data directly? Trust the process. πŸ”₯

Now about that data argument β€” it points to the start of the data field in the record. You can't just guess it, bestie, you have to calculate it: sum up all the field lengths before the field you're operating on, and add that to the base pointer of the record. Math is giving main character energy today. πŸ“βœ¨

⚠️ Note: this function is deprecated and obsolete if PX_retrieve_record(3) is used. Like, she's an icon but she's retired, no cap.

🌈 RETURN VALUE 🌈

  • 0 β€” returned if the value is NULL πŸ™ˆ
  • -1 β€” returned in case of an error 😭
  • 1 β€” returned otherwise, and that's the slay case πŸ‘‘

πŸ’œ SEE ALSO πŸ’œ

the whole friend group fr fr 🫢


πŸ‘‘ AUTHOR πŸ‘‘

This manual page was written by Uwe Steinmann uwe@steinmann.cx. absolute legend, we stan πŸ’–


and that's the whole page, bestie!! it's from the Library Functions Manual, section 3 (PX_GET_DATA_BYTES(3), so you know exactly where to find her again) β€” go forth and free your memory, mwah πŸ’…βœ¨πŸŒΈ