Added mem_realloc and string functions

This commit is contained in:
Jozef Nagy 2025-01-25 23:28:33 +01:00
parent 56c522d05a
commit 12c9b4fdcc
Signed by untrusted user who does not match committer: crz
GPG key ID: 459A4811CEAC7068
10 changed files with 278 additions and 15 deletions

View file

@ -26,7 +26,9 @@
#define BOOTLOADER_VERSION_STR "0.1"
#ifndef UNREACHABLE
#define UNREACHABLE()
#define UNREACHABLE() __builtin_unreachable()
#endif
void axboot_init(void);
#endif /* _AXBOOT_H */

View file

@ -24,11 +24,19 @@
size_t mbstowcs(wchar_t *dest, const char **src, size_t len);
size_t strspn(const char *s, const char *accept);
size_t strcspn(const char *s, const char *reject);
size_t strlen(const char *str);
int strcmp(const char *s1, const char *s2);
int strncmp(const char *s1, const char *s2, size_t n);
char *strcpy(char *dest, const char *src);
char *strdup(const char *s);
char *strtok(char *str, const char *delim);
char *strchr(char *s, int c);
char *strrchr(char *s, int c);
void *memset(void *dest, int val, size_t len);
void *memcpy(void *dest, void *src, size_t len);
void *memcpy(void *dest, const void *src, size_t len);
int memcmp(const void *a, const void *b, size_t len);
#endif /* _LIB_STRING_H */

View file

@ -22,9 +22,18 @@
#include <stddef.h>
// NOTE: If any allocations fail, try increasing this number.
#define MAX_ALLOCATIONS 256
struct alloc_header {
void *addr;
size_t size;
};
void *mem_alloc(size_t n);
int mem_allocat(void *addr, size_t npages);
void *mem_realloc(void *addr, size_t n);
void mem_free(void **addr);
void mem_free(void *addr);
#endif /* _MEM_MMAN_H */

View file

@ -20,6 +20,7 @@
#ifndef _PRINT_H
#define _PRINT_H
#include "nanoprintf.h"
#include <stdarg.h>
#include <stdint.h>
#include <stdbool.h>
@ -29,4 +30,6 @@ void debug(const char *fmt, ...);
void printstr(const char *str);
void snprintf(char *buf, size_t size, const char *fmt, ...);
#endif /* _PRINT_H */