feat: Vfs and Ext2 support. Code style/attribute improvements
Added VFS and Ext2 support. Optimized attributes of methods to improve code highlighting. Printf attribute, malloc attribute, etc.
This commit is contained in:
@@ -22,7 +22,7 @@ void *memset(void *dst, int data, size_t amount) {
|
||||
}
|
||||
|
||||
void *memmove(void *dst, const void *src, size_t amount) {
|
||||
void* tmp = malloc(amount);
|
||||
void *tmp = malloc(amount);
|
||||
if (tmp == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -48,16 +48,19 @@ size_t strlen(const char *str) {
|
||||
}
|
||||
|
||||
int strcmp(const char *s1, const char *s2) {
|
||||
int len1 = strlen(s1);
|
||||
int len2 = strlen(s2);
|
||||
size_t len1 = strlen(s1);
|
||||
size_t len2 = strlen(s2);
|
||||
return strncmp(s1, s2, MAX(len1, len2));
|
||||
}
|
||||
|
||||
const char *strchr(const char *s, char c) {
|
||||
int index = 0;
|
||||
char *strchr(const char *s, char c) {
|
||||
size_t index = 0;
|
||||
while (1) {
|
||||
if (s[index] == c) {
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wincompatible-pointer-types-discards-qualifiers"
|
||||
return &s[index];
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
if (s[index] == 0) {
|
||||
return NULL;
|
||||
@@ -66,11 +69,14 @@ const char *strchr(const char *s, char c) {
|
||||
}
|
||||
}
|
||||
|
||||
const char *strrchr(const char *s, char c) {
|
||||
int index = strlen(s);
|
||||
char *strrchr(const char *s, char c) {
|
||||
size_t index = strlen(s);
|
||||
while (1) {
|
||||
if (s[index] == c) {
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wincompatible-pointer-types-discards-qualifiers"
|
||||
return &s[index];
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
if (index == 0) {
|
||||
return NULL;
|
||||
@@ -90,8 +96,8 @@ int memcmp(const void *s1, const void *s2, size_t n) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int strncmp(const char *s1, const char *s2, int n) {
|
||||
for (int i = 0; i < n; ++i) {
|
||||
int strncmp(const char *s1, const char *s2, size_t n) {
|
||||
for (size_t i = 0; i < n; ++i) {
|
||||
if (s1[i] == 0 && s2[i] == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user