Byte-wise memory functions for C++ macros. More...
| void * | memcpy(void *dst, void *src, int n) |
| void * | memmove(void *dst, void *src, int n) |
| void * | memset(void *dst, int c, int n) |
| int | memcmp(void *a, void *b, int n) |
Byte-wise memory functions for C++ macros. Load with #include <string.h> or #include <cstring> (same plugin). Available from LayoutEditor 20260918.
Do not write #include <string> for this plugin. That name is the C++ string header and is not mapped here. Text in macros is the LayoutEditor string class (length(), +, …).
These four functions work on raw bytes, not on “C strings with a terminating zero” in the usual library sense. strcpy and strcat are not bound — concatenate with string (a = a + b).
memcmp on two LayoutEditor strings compares their UTF-8 bytes.
memcpy / memmove / memset need a real memory address (void *). That is an advanced topic. For comparing text, use memcmp or string operators (==).
#include <string.h>
int main(){
if (memcmp("abc", "abc", 3) != 0) return 1;
if (memcmp("abc", "abd", 3) == 0) return 1;
cout("memcmp ok\n");
}
Copies n bytes from src to dst. The two regions must not overlap. If they might overlap, use memmove.
Parameters:
dst — destination address.src — source address.n (int) — number of bytes. If n ≤ 0, nothing is copied.Returns: dst (the same pointer you passed in). If dst or src is empty, returns dst without copying.
Copies n bytes from src to dst. Overlap is allowed (the function copies in a safe order).
Parameters:
dst — destination address.src — source address.n (int) — number of bytes.Returns: dst.
Fills n bytes at dst with the byte value c (only the lowest 8 bits of c are used). memset(p, 0, n) is a common way to zero memory.
Parameters:
dst — destination address.c (int) — byte value (0 … 255).n (int) — number of bytes.Returns: dst.
Compares n bytes at a with n bytes at b. On two string values this compares the text byte by byte.
Parameters:
a — first block or string.b — second block or string.n (int) — how many bytes to compare. If n ≤ 0, the result is 0.Returns: int
0 if the n bytes are equala is less than b at the first differencea is greater than b at the first differencememcmp("abc", "abd", 3) is not 0. memcmp("abc", "abc", 3) is 0.
Python: compare str / bytes with == and slices. This include is for C++ macros only.