chiark / gitweb /
fix up opening and closing
[chiark-tcl.git] / cdb / writeable.c
index d5c5c5ba8272c4493aa20f0d4fcd62ad1c9fd165..94a7f76a904fd4f7de81477d34c6f8a2985bd85e 100644 (file)
@@ -168,9 +168,9 @@ static int rw_close(Tcl_Interp *ip, Rw *rw) {
   return rc;
 }
 
-static void destroy_cdbrw_idtabcb(Tcl_Interp *ip, void *rw) {
-  rw_close(0,rw);
-  TFREE(rw);
+static void destroy_cdbrw_idtabcb(Tcl_Interp *ip, void *rw_v) {
+  rw_close(0,rw_v);
+  TFREE(rw_v);
 }
 const IdDataSpec cdbtcl_rwdatabases= {
   "cdb-rwdb", "cdb-openrwdatabases-table", destroy_cdbrw_idtabcb
@@ -746,7 +746,7 @@ int cht_do_cdbwr_close(ClientData cd, Tcl_Interp *ip, void *rw_v) {
   else rc= TCL_OK;
 
   if (!rc) {
-    if (!rw->logfile) {
+    if (rw->logfile) {
       logsz= ftello(rw->logfile);
       if (logsz < 0)
        rc= cht_posixerr(ip, errno, "ftell logfile during close info");
@@ -754,7 +754,8 @@ int cht_do_cdbwr_close(ClientData cd, Tcl_Interp *ip, void *rw_v) {
        rc= infocb(ip, rw, "close", "main=%luby log=%luby",
                   rw->mainsz, logsz);
     } else if (reccount>=0) {
-      rc= infocb(ip, rw, "close", "main=%luby nrecs=%l", rw->mainsz, reccount);
+      rc= infocb(ip, rw, "close", "main=%luby nrecs=%ld",
+                rw->mainsz, reccount);
     } else {
       rc= infocb(ip, rw, "close", "main=%luby", rw->mainsz);
     }