From f8681acb374fa0d5ed1568dbedb00a4abe1ca6f1 Mon Sep 17 00:00:00 2001 From: fgergo Date: Sat, 30 Dec 2023 14:58:44 +0100 Subject: [PATCH] ramfs: update to work ramfs: update to work erealloc(p, 0) is handled correctly removed fprint(2, ... removed assert() --- src/cmd/ramfs.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/cmd/ramfs.c b/src/cmd/ramfs.c index 42a38e81..06d1002e 100644 --- a/src/cmd/ramfs.c +++ b/src/cmd/ramfs.c @@ -368,13 +368,11 @@ rwalk(Fid *f) } if(nf != nil && (err!=nil || rhdr.nwqidfid); f->busy = 0; f->ram = nil; } if(rhdr.nwqid == thdr.nwname) /* update the fid after a successful walk */ f->ram = fram; - assert(f->busy); return err; } @@ -615,8 +613,6 @@ rclunk(Fid *f) f->ram->open--; if(f->rclose) e = realremove(f->ram); -fprint(2, "clunk fid %d busy=%d\n", f->fid, f->busy); -fprint(2, "f %d zero busy\n", f->fid); f->busy = 0; f->open = 0; f->ram = 0; @@ -630,7 +626,6 @@ rremove(Fid *f) if(f->open) f->ram->open--; -fprint(2, "f %d zero busy\n", f->fid); f->busy = 0; f->open = 0; r = f->ram; @@ -874,6 +869,10 @@ emalloc(ulong n) void * erealloc(void *p, ulong n) { + if(n == 0) { + free(p); + return nil; + } p = realloc(p, n); if(!p) error("out of memory");