String and memory operations. More...
#include <core.h>
Go to the source code of this file.
Functions | |
size_t | strlen (const char *str) |
Return the length of a null-terminated string. More... | |
size_t | strlcpy (char *dst, const char *src, size_t dstsize) |
Copy the source string to the destination buffer. More... | |
size_t | strlcat (char *dst, const char *src, size_t dstsize) |
Append the source string to the end of the destination string. More... | |
int | strcmp (const char *str1, const char *str2) |
Compare two strings and return a value indicating their lexicographical order. More... | |
void * | memcpy (void *dst, const void *src, size_t num) |
Copy bytes from one memory region to another. More... | |
void * | memmove (void *dst, const void *src, size_t num) |
Move bytes from one memory region to another, even if the regions overlap. More... | |
void * | memset (void *dst, int b, size_t num) |
Fill a region of memory with a single byte value. More... | |
void * | memsetw (void *dst, int w, size_t num) |
Fill a region of memory with a single 16-bit word value. More... | |
void * | memsetd (void *dst, uint32_t d, size_t num) |
Fill a region of memory with a single 32-bit dword value. More... | |
void * | memzero (void *dst, size_t num) |
Fill a region of memory with zeroes. More... | |
String and memory operations.
Definition in file string.h.
size_t strlen | ( | const char * | str | ) |
Return the length of a null-terminated string.
Count the number of characters in the null-terminated string and return the count.
[in] | str | Pointer to a null-terminated string. |
Referenced by add_msg().
size_t strlcpy | ( | char * | dst, |
const char * | src, | ||
size_t | dstsize | ||
) |
Copy the source string to the destination buffer.
Appends string src to the end of dst. It will copy at most dstsize - 1 characters. A null terminator is added to the end of the destination string unless dstsize was 0.
[in] | dst | Pointer to the destination buffer. |
[in] | src | Pointer to the source string. |
[in] | dstsize | Maximum number of characters in the dst buffer after copying, including the null terminator. |
size_t strlcat | ( | char * | dst, |
const char * | src, | ||
size_t | dstsize | ||
) |
Append the source string to the end of the destination string.
The function will append at most dstsize - strlen(dst) - 1 characters. A null terminator is added to the end of the concatenated string unless dstsize was 0.
[in] | dst | Pointer to the destination string. |
[in] | src | Pointer to the source string. |
[in] | dstsize | Maximum number of characters in the dst buffer after concatenation, including the null terminator. |
int strcmp | ( | const char * | str1, |
const char * | str2 | ||
) |
Compare two strings and return a value indicating their lexicographical order.
String comparison continues until a null terminator is reached in one of the strings.
[in] | str1 | Pointer to the first string. |
[in] | str2 | Pointer to the second string. |
Referenced by cmp_cmds(), and command_exec().
void* memcpy | ( | void * | dst, |
const void * | src, | ||
size_t | num | ||
) |
Copy bytes from one memory region to another.
If the memory regions overlap, this function's behavior is undefined, and you should use memmove instead.
[in] | dst | Address of the destination memory area. |
[in] | src | Address of the source memory area. |
[in] | num | Number of bytes to copy. |
Referenced by add_msg(), kb_init(), kb_setlayout(), and tty_printchar().
void* memmove | ( | void * | dst, |
const void * | src, | ||
size_t | num | ||
) |
Move bytes from one memory region to another, even if the regions overlap.
[in] | dst | Address of the destination memory area. |
[in] | src | Address of the source memory area. |
[in] | num | Number of bytes to copy. |
Referenced by collapse(), insertafter(), and log_removecallback().
void* memset | ( | void * | dst, |
int | b, | ||
size_t | num | ||
) |
Fill a region of memory with a single byte value.
[in] | dst | Address of the destination memory area. |
[in] | b | Value of the byte used to fill memory. |
[in] | num | Number of bytes to set. |
void* memsetw | ( | void * | dst, |
int | w, | ||
size_t | num | ||
) |
Fill a region of memory with a single 16-bit word value.
[in] | dst | Address of the destination memory area. |
[in] | w | Value of the word used to fill memory. |
[in] | num | Number of words to set. |
Referenced by tty_clear(), and tty_printchar().
void* memsetd | ( | void * | dst, |
uint32_t | d, | ||
size_t | num | ||
) |
Fill a region of memory with a single 32-bit dword value.
[in] | dst | Address of the destination memory area. |
[in] | d | Value of the dword used to fill memory. |
[in] | num | Number of dwords to set. |
void* memzero | ( | void * | dst, |
size_t | num | ||
) |
Fill a region of memory with zeroes.
[in] | dst | Address of the destination memory area. |
[in] | num | Number of bytes to set to zero. |
Referenced by alloc_page(), kb_init(), kmem_init(), page_init(), pagetable_destroy(), pfalloc(), pffree(), and pgalloc().