From: Arne Meyer <meyer.arne83@netcologne.de>
To: "9front@9front.org" <9front@9front.org>
Subject: [9front] [patch] archfs replace hand rolled emalloc wit emalloc9p
Date: Fri, 13 Jan 2023 18:23:54 +0100 (CET) [thread overview]
Message-ID: <1612482052.2056775.1673630634217@comcenter.netcologne.de> (raw)
[-- 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--;
reply other threads:[~2023-01-13 17:25 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1612482052.2056775.1673630634217@comcenter.netcologne.de \
--to=meyer.arne83@netcologne.de \
--cc=9front@9front.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).