[-- Attachment #1: Type: text/plain, Size: 87 bytes --] Hello, lib9p already has what we need. No need to reinvent the wheel. Greetings, Arne [-- Attachment #2: archfs.patch --] [-- Type: application/octet-stream, Size: 1011 bytes --] diff c10be29c773737c4159b613f4f6c3b5a90d732f6 uncommitted --- a/sys/src/cmd/archfs.c +++ b/sys/src/cmd/archfs.c @@ -26,28 +26,7 @@ vlong length; }; -static void* -emalloc(long sz) -{ - void *v; - - v = malloc(sz); - if(v == nil) - sysfatal("malloc %lud fails", sz); - memset(v, 0, sz); - return v; -} - static char* -estrdup(char *s) -{ - s = strdup(s); - if(s == nil) - sysfatal("strdup (%.10s) fails", s); - return s; -} - -static char* Bgetline(Biobuf *b) { char *p; @@ -76,11 +55,11 @@ return nil; } - a = emalloc(sizeof(*a)); - a->name = estrdup(f[0]); + a = emalloc9p(sizeof(*a)); + a->name = estrdup9p(f[0]); a->mode = strtoul(f[1], 0, 8); - a->uid = estrdup(f[2]); - a->gid = estrdup(f[3]); + a->uid = estrdup9p(f[2]); + a->gid = estrdup9p(f[3]); a->mtime = strtoll(f[4], 0, 10); a->length = strtoll(f[5], 0, 10); return a; @@ -94,7 +73,7 @@ if(nabuf == 0) { nabuf = 256; - abuf = emalloc(sizeof(Arch)*nabuf); + abuf = emalloc9p(sizeof(Arch)*nabuf); } nabuf--;