Ditch dlmalloc in favour of custom umalloc

This commit is contained in:
2025-09-27 22:32:38 +02:00
parent 3b1bb9d531
commit 8d081bedb0
13 changed files with 114 additions and 110 deletions

View File

@ -61,8 +61,8 @@ void pctl_ls(void) {
uint64_t procslen = processctl(-1, PCTL_PLS_SZ, 0, 0, 0);
char *namebuf = dlmalloc(34);
char *membuf = dlmalloc(20);
char *namebuf = umalloc(34);
char *membuf = umalloc(20);
uprintf("%-30s %s %-6s %-15s %-8s\n", "NAME", "PID", "TYPE", "MEMORY", "STATE");
for (size_t i = 0; i < procslen; i++) {

View File

@ -28,25 +28,25 @@ void tz_tokenize(Tokenizer *tz) {
size_t len = string_len(tz->str);
for (size_t i = 0; i < len; i++) {
if (tz->str[i] == '\'') {
char *str = dlmalloc(TZ_MAX_TK);
char *str = umalloc(TZ_MAX_TK);
string_memset(str, 0, TZ_MAX_TK);
i++;
size_t j = 0;
while (i < len && tz->str[i] != '\'') {
str[j++] = tz->str[i++];
}
Token *tk = dlmalloc(sizeof(*tk));
Token *tk = umalloc(sizeof(*tk));
tk->str = str;
tk->next = NULL;
LL_APPEND(tz->tokens, tk);
} else {
char *tkstr = dlmalloc(TZ_MAX_TK);
char *tkstr = umalloc(TZ_MAX_TK);
string_memset(tkstr, 0, TZ_MAX_TK);
size_t j = 0;
while (i < len && !string_chr_isspace(tz->str[i])) {
tkstr[j++] = tz->str[i++];
}
Token *tk = dlmalloc(sizeof(*tk));
Token *tk = umalloc(sizeof(*tk));
tk->str = tkstr;
tk->next = NULL;
LL_APPEND(tz->tokens, tk);

View File

@ -64,7 +64,7 @@ void do_file(char *filepath) {
LOG(LOG_ERR, "{s} is not a file ({d})\n", filepath, statbuf.type);
return;
}
uint8_t *buf = dlmalloc(statbuf.size+1);
uint8_t *buf = umalloc(statbuf.size+1);
string_memset(buf, 0, statbuf.size+1);
if ((ret = ioctl(ioh, IOCTL_READ, (uint64_t)buf, statbuf.size, 0)) < 0) {

View File

@ -9,7 +9,7 @@ RtAlias *RTALIASES = NULL;
#define RTCMD(name, _fn) \
do { \
RtCmd *_cmd = dlmalloc(sizeof(*_cmd)); \
RtCmd *_cmd = umalloc(sizeof(*_cmd)); \
_cmd->cmdname = (name); \
_cmd->fn = (_fn); \
LL_APPEND(RTCMDS, _cmd); \
@ -28,7 +28,7 @@ bool rt_print(Token *tks) {
}
bool rt_mkalias(Token *tks) {
RtAlias *alias = dlmalloc(sizeof(*alias));
RtAlias *alias = umalloc(sizeof(*alias));
string_memset(alias, 0, sizeof(*alias));
size_t i;