string provides a minimal set of string utilities for bare-metal use. It is compiled with -nostdlib and therefore cannot include the standard <string.h>. Only the operations actually required by the OS are implemented.
This library does not expose
strlen, strcpy, strcmp, memset, or memcpy. The sole function is my_strncpy, which covers the one safe-copy use case needed in the project.my_strncpy
n characters from src into dest. If src is shorter than n characters, the remainder of dest is filled with null bytes. The destination is always null-padded up to n bytes, but it is not guaranteed to be null-terminated when src is exactly n characters long.
Parameters
| Parameter | Type | Description |
|---|---|---|
dest | char * | Destination buffer. Must have room for at least n bytes. |
src | const char * | Source string to copy from. |
n | size_t | Maximum number of characters to copy. |
Return value
Returnsdest.