diff options
author | Nicholas <nbnoll@eml.cc> | 2021-11-12 09:22:01 -0800 |
---|---|---|
committer | Nicholas <nbnoll@eml.cc> | 2021-11-12 09:22:01 -0800 |
commit | ce05175372a9ddca1a225db0765ace1127a39293 (patch) | |
tree | 5988b4d4f6b402e4953945886fc90aae11203df6 /sys/cmd/rc/util.c | |
parent | b375f3cdedb5b0e08745d100b40e38d2f8396a58 (diff) |
chore: simplified organizational structurelaptop
Diffstat (limited to 'sys/cmd/rc/util.c')
-rw-r--r-- | sys/cmd/rc/util.c | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/sys/cmd/rc/util.c b/sys/cmd/rc/util.c deleted file mode 100644 index b0be788..0000000 --- a/sys/cmd/rc/util.c +++ /dev/null @@ -1,65 +0,0 @@ -#include "rc.h" - -void -fatal(char *msg, ...) -{ - va_list args; - vfprintf(stderr, msg, args); - va_end(args); - - abort(); -} - -void* -emalloc(uintptr n) -{ - void *p; - if(!(p = malloc(n))) - fatal("out of memory: can't allocate %d bytes", n); - - memset(p, 0, n); - return p; -} - -void* -erealloc(void *p, uintptr n) -{ - void *r; - if(!(r = realloc(p,n))) - fatal("out of memory: can't reallocate %d bytes", n); - - return r; -} - -void -efree(void *p) -{ - if(p) - free(p); - // TODO: log the double free -} - - -char *bp; - -static -void -iacvt(int n) -{ - if(n<0){ - *bp++='-'; - n=-n; /* doesn't work for n==-inf */ - } - if(n/10) - iacvt(n/10); - - *bp++=n%10+'0'; -} - -void -itoa(char *s, long n) -{ - bp = s; - iacvt(n); - *bp='\0'; -} |