feat: reformatted code base to be more standard
This commit is contained in:
@@ -2,16 +2,29 @@
|
||||
// Created by rick on 01-02-21.
|
||||
//
|
||||
|
||||
#include <libc/string.h>
|
||||
#include <stdbool.h>
|
||||
#include <libc/libc.h>
|
||||
#include <types.h>
|
||||
#include <string.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
int memcpy(void *dst, const void *src, size_t amount) {
|
||||
for (size_t i = 0; i < amount; i++) {
|
||||
((char *) dst)[i] = ((const char *) src)[i];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int memset(void *dst, int data, size_t amount) {
|
||||
for (size_t i = 0; i < amount; ++i) {
|
||||
((char *) dst)[i] = (char) data;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int strcpy(char *dst, char *src) {
|
||||
return memcpy(dst, src, strlen(src) + 1);
|
||||
}
|
||||
|
||||
int strlen(const char *str) {
|
||||
size_t strlen(const char *str) {
|
||||
int length = 0;
|
||||
while (str[length] != 0) {
|
||||
length++;
|
||||
@@ -22,12 +35,12 @@ int strlen(const char *str) {
|
||||
int strcmp(const char *s1, const char *s2) {
|
||||
int len1 = strlen(s1);
|
||||
int len2 = strlen(s2);
|
||||
return strncmp(s1, s2, maxi(len1, len2));
|
||||
return strncmp(s1, s2, MAX(len1, len2));
|
||||
}
|
||||
|
||||
const char *strchr(const char *s, char c) {
|
||||
int index = 0;
|
||||
while (true) {
|
||||
while (1) {
|
||||
if (s[index] == c) {
|
||||
return &s[index];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user