umalloc fixes
This commit is contained in:
@ -6,6 +6,9 @@
|
||||
#include <system/system.h>
|
||||
#include <sysdefs/devctl.h>
|
||||
#include <write/write.h>
|
||||
#include <umalloc/umalloc.h>
|
||||
#include <string/string.h>
|
||||
#include <util/util.h>
|
||||
|
||||
char *utoa(uintmax_t v, int base, bool uppercase) {
|
||||
if (base < 2 || base > 36) {
|
||||
@ -76,7 +79,7 @@ char *itoa(intmax_t v, int base, bool uppercase) {
|
||||
return &buf[i];
|
||||
}
|
||||
|
||||
#define FMTBUF_MAX 2048
|
||||
#define FMTBUF_MAX (1024 * 4)
|
||||
|
||||
extern Dev_t termdev;
|
||||
|
||||
@ -88,16 +91,15 @@ enum {
|
||||
const char *convstr1 = "0123456789abcdef";
|
||||
const char *convstr2 = "0123456789ABCDEF";
|
||||
|
||||
void writefmt(char *fmt, ...) {
|
||||
size_t writefmt(char *fmt, ...) {
|
||||
va_list list;
|
||||
va_start(list, fmt);
|
||||
writevfmt(fmt, list);
|
||||
size_t count = writevfmt(fmt, list);
|
||||
va_end(list);
|
||||
return count;
|
||||
}
|
||||
|
||||
#define ITOA_BUF_SIZE 32
|
||||
|
||||
void writevsfmt(char *buf, char *fmt, va_list list) {
|
||||
size_t writevsfmt(char *buf, char *fmt, va_list list) {
|
||||
size_t c = 0;
|
||||
int WRITE_STATE = WRITE_NORMALMODE;
|
||||
|
||||
@ -118,44 +120,48 @@ void writevsfmt(char *buf, char *fmt, va_list list) {
|
||||
break;
|
||||
case 's': {
|
||||
char *string = va_arg(list, char *);
|
||||
while (*string) { buf[c++] = *string; string++; }
|
||||
while (string && *string) { buf[c++] = *string; string++; }
|
||||
} break;
|
||||
case 'd': {
|
||||
int int1 = va_arg(list, int);
|
||||
char *string = itoa(int1, 10, false);
|
||||
while (*string) { buf[c++] = *string; string++; }
|
||||
while (string && *string) { buf[c++] = *string; string++; }
|
||||
} break;
|
||||
case 'x': {
|
||||
unsigned int int1 = va_arg(list, unsigned int);
|
||||
char *string = utoa(int1, 16, false);
|
||||
while (*string) { buf[c++] = *string; string++; }
|
||||
while (string && *string) { buf[c++] = *string; string++; }
|
||||
} break;
|
||||
case 'X': {
|
||||
unsigned int int1 = va_arg(list, unsigned int);
|
||||
char *string = utoa(int1, 16, true);
|
||||
while (*string) { buf[c++] = *string; string++; }
|
||||
while (string && *string) { buf[c++] = *string; string++; }
|
||||
} break;
|
||||
case 'p': {
|
||||
uintptr_t ptr = (uintptr_t)va_arg(list, void *);
|
||||
char *string = utoa(ptr, 16, false);
|
||||
while (*string) { buf[c++] = *string; string++; }
|
||||
while (string && *string) { buf[c++] = *string; string++; }
|
||||
} break;
|
||||
case 'P': {
|
||||
uintptr_t ptr = (uintptr_t)va_arg(list, void *);
|
||||
char *string = utoa(ptr, 16, true);
|
||||
while (*string) { buf[c++] = *string; string++; }
|
||||
while (string && *string) { buf[c++] = *string; string++; }
|
||||
} break;
|
||||
case 'c': {
|
||||
char c1 = (char)va_arg(list, char);
|
||||
buf[c++] = c1;
|
||||
int c1 = va_arg(list, int);
|
||||
buf[c++] = (char)c1;
|
||||
} break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
void writevfmt(char *fmt, va_list list) {
|
||||
size_t writevfmt(char *fmt, va_list list) {
|
||||
char buf[FMTBUF_MAX];
|
||||
writevsfmt(buf, fmt, list);
|
||||
devctl(&termdev, 0x00, buf, sizeof(buf), 0);
|
||||
string_memset(buf, 0, FMTBUF_MAX);
|
||||
size_t count = writevsfmt(buf, fmt, list);
|
||||
devctl(&termdev, 0x00, buf, count, 0);
|
||||
return count;
|
||||
}
|
||||
|
Reference in New Issue
Block a user