libfuncs.h¶
-
int memcmp(const void *vl, const void *vr, u64 n)¶
Compares the first n bytes (each interpreted as unsigned char) of the memory areas s1 and s2.
- Parameters
vl – left array
vr – right array
n – number of bytes to compare
- Returns
TODO, an integer
- Since
v0.1
-
void *memcpy(void *dst0, const void *src0, u64 length)¶
Copies a number of bytes set by length from scr0 to dst0. TODO is “0” needed for “src0” and “dst0” at all?
- Parameters
dst0 – destination void pointer to copy bytes to
src0 – source void pointer to copy bytes from
length – a length of bytes to copy, unsigned 64-bit integer
- Returns
a void pointer, dst0
- Since
v0.1
-
void *memmove(void *s1, const void *s2, u64 n)¶
Copies a memory area of a given length from “s2” to “s1”, given a length.
- Parameters
s2 – a destination byte array
s1 – a source byte array
n – a number of bytes to copy
- Since
v0.1
-
void *memset(void *dest, int c, u64 n)¶
Fills a bytearray with a certain byte given a maximum number of bytes to fill.
- Parameters
dest – a destination bytearray pointer
c – a byte to copy (TODO check)
n – a number of bytes to copy (TODO check)
- Since
v0.1
-
u64 strlen(char *str)¶
Calculates the length of the string pointed to by “str” parameter, excluding the terminating null byte (‘0’).
- Parameters
str – a char array input pointer
- Returns
an actual length of a string or 0
- Since
v0.1
-
u64 strnlen_s(char *str, u64 max_len)¶
Calculates the length of the string, excluding the first null character terminating it. Stops counting when “max_len” is reached, returns “max_len” in that case.
TODO: check if this implementation should be used. https://stackoverflow.com/questions/66346502/
- Returns
string length (for a null-terminated byte string)
- Since
v0.1
-
char *strcpy(char *dest, char *src)¶
Copies the string pointed by src to the buffer pointed to by dest. Includes the terminating null byte (‘0’).
The destination string dest must be large enough to store the copy.
- Parameters
dest – the pointer to the bytearray to write to
src – the pointer to the source bytearray
- Returns
the dest pointer
- Since
v0.1
-
char *strncpy(char *dest, char *src, u64 max_len)¶
Copies a string.
- Parameters
dest – a destination bytearray pointer to copy bytes to
src – a source bytearray pointer to copy bytes from
max_len – a maximum length of a string to copy, an unsigned 64-bit integer
- Returns
a destination bytearray pointer
- Since
v0.1
-
int strcmp(const char *s1, const char *s2)¶
Compares two strings.
- Parameters
s1 – string A
s2 – string B
- Returns
an integer less than 0 if s1 is less than s2, zero if s1 matches s2, greater than zero if s1 is greater than s2
- Since
v0.1
-
int strncmp(const char *s1, const char *s2, u64 n)¶
Compares two strings.
- Parameters
s1 – string A
s2 – string B
n – a number of characters to compare, a 64-bit unsigned integer
- Returns
an integer less than 0 if s1 is less than s2, zero if s1 matches s2, greater than zero if s1 is greater than s2
- Since
v0.1
-
void strcat(char *dest, char *src)¶
Concatenates two strings, appends “src” string to “dest” one. Overwrites a null-terminating byte and terminates it later. TODO check if termination happens. “dest” character array must have enough space for this operation.
- Parameters
dest – destination character array pointer
src – source character array pointer
- Since
v0.1