LumaOS  v0.1.116
An experimental x86-64 OS
Loading...
Searching...
No Matches
kstring.c File Reference

Utilities for memory and string operations. More...

#include <stddef.h>
#include <stdbool.h>
#include <stdint.h>
#include <lib/kstring.h>
Include dependency graph for kstring.c:

Go to the source code of this file.

Functions

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.

Detailed Description

Utilities for memory and string operations.

Author
Matheus Boscariol
Since
30/10/2026

Definition in file kstring.c.

Function Documentation

◆ 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
valueThe value to convert into hex
buffBuffer to hold the new string
char_limitMax 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
valueThe value to turn into a string
buffThe 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
aThe first value to compare
bThe second value to compare
nThe 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
destDestination pointer
srcSource pointer
nAmount 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
destDestination pointer
srcSource pointer
nAmount 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
destDestination pointer
cThe value to be copied
nNumber 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
str1The first (destination) string
str2The second string
Returns
The address of the first (destination) string

Definition at line 107 of file kstring.c.

Here is the call graph for this function:

◆ strcmp()

int strcmp ( const char * s1,
const char * s2 )

Compares 2 strings.

Parameters
s1First string
s2Second 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
strThe string
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
s1First string
s2Second String
nThe 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.