MEMCPY(3POSIX)

πŸ’– MEMCPY(3POSIX) β€” bestie's guide to copying bytes πŸ’–

okay so this is a page from the POSIX Programmer's Manual (you know, the 3POSIX section, not the Linux one). hi bestie 🫢


🌸 PROLOG 🌸

okay so real talk before we get into it: this manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (so like, go check the corresponding Linux manual page for the deets on Linux behavior), or honestly the interface may not even be implemented on Linux. no cap. πŸ™ˆ


✨ NAME ✨

memcpy β€” copy bytes in memory. that's it. that's the girl. πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

#include <string.h>

void *memcpy(void *restrict s1, const void *restrict s2, size_t n);

look at her. iconic signature. ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

so the functionality described on this reference page is aligned with the ISO C standard. and like, if there's any conflict between the requirements described here and the ISO C standard, that conflict is unintentional β€” this volume of POSIX.1‐2017 defers to the ISO C standard. periodt. πŸ’―

okay now the actual tea β˜•: the memcpy() function shall copy n bytes from the object pointed to by s2 into the object pointed to by s1.

⚠️ BIG ONE, PAY ATTENTION: if copying takes place between objects that overlap, the behavior is undefined. like, undefined-undefined. do not do this. this is not the vibe. πŸ’€

πŸ”₯ RETURN VALUE πŸ”₯

the memcpy() function shall return s1. and listen β€” no return value is reserved to indicate an error. she doesn't do error codes. she's not that kind of girl. 😌


πŸ’œ ERRORS πŸ’œ

No errors are defined. literally zero. none. not a single one. πŸ’€

also fyi: the following sections are informative (so like, they're the extra commentary, not the rules).


🌈 EXAMPLES 🌈

None. she said no examples, we respect it. πŸ™ˆ


πŸ’… APPLICATION USAGE πŸ’…

heads up bestie: the memcpy() function does not check for the overflow of the receiving memory area. so if you hand her a s1 that's too small… that's on you, not her. 🫢 please size your buffers. i'm begging. 😭


⭐ RATIONALE ⭐

None. nothing to explain. she simply is. πŸ‘‘


🧚 FUTURE DIRECTIONS 🧚

None. the future is unwritten but memcpy is eternal. ✨


🌸 SEE ALSO 🌸

  • The Base Definitions volume of POSIX.1‐2017, <string.h>

go read that one too, iykyk. πŸ“š


okay legal moment, but make it cute:

Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group.

In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .

Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .


and that's the whole page bestie πŸŽ€ this one came from IEEE/The Open Group, dated 2017, and yes the header and footer both just say MEMCPY(3POSIX) πŸ’– go forth and copy bytes responsibly, and for the love of everything do not overlap them πŸ’…βœ¨