From 4b5766580559d101dd1c29cc575b3ffa9f51c2d7 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Mon, 23 Sep 2013 23:16:25 +0200 Subject: fossil: move from liboventi to libthread and libventi R=rsc https://codereview.appspot.com/13504049 --- src/cmd/fossil/Ccli.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) (limited to 'src/cmd/fossil/Ccli.c') diff --git a/src/cmd/fossil/Ccli.c b/src/cmd/fossil/Ccli.c index 775cb620..52a91474 100644 --- a/src/cmd/fossil/Ccli.c +++ b/src/cmd/fossil/Ccli.c @@ -8,7 +8,7 @@ typedef struct { } Cmd; static struct { - VtLock* lock; + QLock lock; Cmd* cmd; int ncmd; int hi; @@ -26,7 +26,7 @@ cliError(char* fmt, ...) va_start(arg, fmt); p = vsmprint(fmt, arg); - vtSetError("%s", p); + werrstr("%s", p); free(p); va_end(arg); @@ -39,32 +39,32 @@ cliExec(char* buf) int argc, i, r; char *argv[20], *p; - p = vtStrDup(buf); + p = vtstrdup(buf); if((argc = tokenize(p, argv, nelem(argv)-1)) == 0){ - vtMemFree(p); + vtfree(p); return 1; } argv[argc] = 0; if(argv[0][0] == '#'){ - vtMemFree(p); + vtfree(p); return 1; } - vtLock(cbox.lock); + qlock(&cbox.lock); for(i = 0; i < cbox.hi; i++){ if(strcmp(cbox.cmd[i].argv0, argv[0]) == 0){ - vtUnlock(cbox.lock); + qunlock(&cbox.lock); if(!(r = cbox.cmd[i].cmd(argc, argv))) - consPrint("%s\n", vtGetError()); - vtMemFree(p); + consPrint("%r\n"); + vtfree(p); return r; } } - vtUnlock(cbox.lock); + qunlock(&cbox.lock); consPrint("%s: - eh?\n", argv[0]); - vtMemFree(p); + vtfree(p); return 0; } @@ -75,16 +75,16 @@ cliAddCmd(char* argv0, int (*cmd)(int, char*[])) int i; Cmd *opt; - vtLock(cbox.lock); + qlock(&cbox.lock); for(i = 0; i < cbox.hi; i++){ if(strcmp(argv0, cbox.cmd[i].argv0) == 0){ - vtUnlock(cbox.lock); + qunlock(&cbox.lock); return 0; } } if(i >= cbox.hi){ if(cbox.hi >= cbox.ncmd){ - cbox.cmd = vtMemRealloc(cbox.cmd, + cbox.cmd = vtrealloc(cbox.cmd, (cbox.ncmd+NCmdIncr)*sizeof(Cmd)); memset(&cbox.cmd[cbox.ncmd], 0, NCmdIncr*sizeof(Cmd)); cbox.ncmd += NCmdIncr; @@ -95,7 +95,7 @@ cliAddCmd(char* argv0, int (*cmd)(int, char*[])) opt->argv0 = argv0; opt->cmd = cmd; cbox.hi++; - vtUnlock(cbox.lock); + qunlock(&cbox.lock); return 1; } @@ -103,8 +103,7 @@ cliAddCmd(char* argv0, int (*cmd)(int, char*[])) int cliInit(void) { - cbox.lock = vtLockAlloc(); - cbox.cmd = vtMemAllocZ(NCmdIncr*sizeof(Cmd)); + cbox.cmd = vtmallocz(NCmdIncr*sizeof(Cmd)); cbox.ncmd = NCmdIncr; cbox.hi = 0; -- cgit v1.2.3