libc

my libc
git clone git://git.evenfri.duckdns.org/libc.git
Log | Files | Refs | README

commit 8d082c0dd94ebc80a58f143e099f079bf9d5cb9c
parent 6a837b5cd9698db9a446928e665cc62d7ca68994
Author: evenfri <evenfri256@gmail.com>
Date:   Sun,  9 Aug 2026 01:52:46 +0800

fix strchr, getents

Diffstat:
Mgetdents.c | 7++++++-
Mmalloc.c | 2+-
Mstrchr.c | 2++
3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/getdents.c b/getdents.c @@ -6,5 +6,10 @@ #include "libc.h" int getdents64(int fd, struct linux_dirent64 *dirp, unsigned int count) { - return (int)syscall(sys_getdents64, fd, (long)dirp, count); + int ret = syscall(sys_getdents64, fd, (long)dirp, count); + if (ret < 0) { + errno = -ret; + return -1; + } + return ret; } diff --git a/malloc.c b/malloc.c @@ -12,7 +12,7 @@ struct block_header { size_t size; int is_free; struct block_header *next; -}; +} __attribute__((aligned(16))); typedef struct block_header block_header_t; diff --git a/strchr.c b/strchr.c @@ -12,6 +12,8 @@ char *strchr(const char *s, int c) { while (s[i] != 0) { if (s[i] == chr) return (char*)s + i; + if (s[i] == '\0') + return NULL; i++; }