Utilities for memory and string operations.
More...
#include <stddef.h>
#include <stdbool.h>
#include <stdint.h>
#include <lib/kstring.h>
Go to the source code of this file.
|
| void * | memcpy (void *dest, const void *src, size_t n) |
| | Copies memory from one address to the other without overlapping.
|
| void * | memmove (void *dest, const void *src, size_t n) |
| | Copies memory from one address to the other with possible overlap.
|
| void * | memset (void *dest, int c, size_t n) |
| | Fills n bytes of the destination with c.
|
| int | memcmp (const void *a, const void *b, const size_t n) |
| | Compares 2 the value of 2 memory addresses.
|
| int | strcmp (const char *s1, const char *s2) |
| | Compares 2 strings.
|
| int | strncmp (const char *s1, const char *s2, size_t n) |
| | Compares 2 strings up to n characters.
|
| size_t | strlen (const char *str) |
| | Calculates the length of a string.
|
| char * | strcat (char *str1, const char *str2) |
| | Concatenates (joins) 2 strings.
|
| char * | int_to_str (const uint64_t value, char *buff) |
| | Converts an integer to a string.
|
| void | int_to_hex_str (const unsigned long long value, char *buff, const uint8_t char_limit) |
| | Converts an integer value into a hex string.
|
Utilities for memory and string operations.
- Author
- Matheus Boscariol
- Since
- 30/10/2026
- Copyright
- (c) 2026 Matheus Boscariol. Licensed under GNU AGPL-3.0.
Definition in file kstring.c.
◆ int_to_hex_str()
| void int_to_hex_str |
( |
unsigned long long | value, |
|
|
char * | buff, |
|
|
uint8_t | char_limit ) |
Converts an integer value into a hex string.
- Parameters
-
| value | The value to convert into hex |
| buff | Buffer to hold the new string |
| char_limit | Max characters in the string |
- Todo
- rewrite this function
Definition at line 165 of file kstring.c.
◆ int_to_str()
| char * int_to_str |
( |
uint64_t | value, |
|
|
char * | buff ) |
Converts an integer to a string.
- Parameters
-
| value | The value to turn into a string |
| buff | The buffer to hold the string |
- Returns
- The address of the buffer
Definition at line 120 of file kstring.c.
◆ memcmp()
| int memcmp |
( |
const void * | a, |
|
|
const void * | b, |
|
|
size_t | n ) |
Compares 2 the value of 2 memory addresses.
- Parameters
-
| a | The first value to compare |
| b | The second value to compare |
| n | The amount of bytes to compare |
- Returns
- -1 if a < b
-
0 if a = b
-
1 if a > b
Definition at line 52 of file kstring.c.
◆ memcpy()
| void * memcpy |
( |
void * | dest, |
|
|
const void * | src, |
|
|
size_t | n ) |
Copies memory from one address to the other without overlapping.
- Parameters
-
| dest | Destination pointer |
| src | Source pointer |
| n | Amount of bytes to copy |
- Returns
- the address of the destination
Definition at line 14 of file kstring.c.
◆ memmove()
| void * memmove |
( |
void * | dest, |
|
|
const void * | src, |
|
|
size_t | n ) |
Copies memory from one address to the other with possible overlap.
- Parameters
-
| dest | Destination pointer |
| src | Source pointer |
| n | Amount of bytes to copy |
- Returns
- the address of the destination
Definition at line 26 of file kstring.c.
◆ memset()
| void * memset |
( |
void * | dest, |
|
|
int | c, |
|
|
size_t | n ) |
Fills n bytes of the destination with c.
- Parameters
-
| dest | Destination pointer |
| c | The value to be copied |
| n | Number of bytes to copy it to |
- Returns
- The address of the destination
Definition at line 44 of file kstring.c.
◆ strcat()
| char * strcat |
( |
char * | str1, |
|
|
const char * | str2 ) |
Concatenates (joins) 2 strings.
- Parameters
-
| str1 | The first (destination) string |
| str2 | The second string |
- Returns
- The address of the first (destination) string
Definition at line 107 of file kstring.c.
◆ strcmp()
| int strcmp |
( |
const char * | s1, |
|
|
const char * | s2 ) |
Compares 2 strings.
- Parameters
-
| s1 | First string |
| s2 | Second String |
- Returns
- 0 if s1 = s2
-
-1 if s1 < s2
-
1 if s1 > s2
Definition at line 66 of file kstring.c.
◆ strlen()
| size_t strlen |
( |
const char * | str | ) |
|
Calculates the length of a string.
- Parameters
-
- Returns
- The length of the string (excluding \0)
Definition at line 92 of file kstring.c.
◆ strncmp()
| int strncmp |
( |
const char * | s1, |
|
|
const char * | s2, |
|
|
size_t | n ) |
Compares 2 strings up to n characters.
- Parameters
-
| s1 | First string |
| s2 | Second String |
| n | The amount of characters to compare |
- Returns
- 0 if s1 = s2
-
-1 if s1 < s2
-
1 if s1 > s2
Definition at line 77 of file kstring.c.