]> git.pond.sub.org Git - empserver/commitdiff
(ef_open): EFF_STATIC and cache not null can't happen.
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 30 Oct 2005 18:48:55 +0000 (18:48 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 30 Oct 2005 18:48:55 +0000 (18:48 +0000)
(ef_open): Leave check of fd to do_write().

src/lib/common/file.c

index 76c5733563b18185d0d352743df8ec7481dfb149..bf8be5c10561898048de0898641a7de2467de073 100644 (file)
@@ -114,6 +114,8 @@ ef_open(int type, int how)
        else
            ep->csize = max(1, blksize(fd) / ep->size);
        size = ep->csize * ep->size;
+       if (CANT_HAPPEN(ep->cache))
+           free(ep->cache);
        ep->cache = malloc(size);
        if (ep->cache == NULL && size) {
            logerror("Can't open %s: out of memory", ep->file);
@@ -136,6 +138,11 @@ ef_open(int type, int how)
        }
     }
 
+    /*
+     * Could close fd if both EFF_RDONLY and EFF_MEM, but that doesn't
+     * happen, so don't bother.
+     */
+
     return 1;
 }
 
@@ -345,8 +352,6 @@ ef_write(int type, int id, void *from)
     if (ef_check(type) < 0)
        return 0;
     ep = &empfile[type];
-    if (CANT_HAPPEN(ep->fd < 0))
-       return 0;
     if (ep->prewrite)
        ep->prewrite(id, from);
     if (CANT_HAPPEN((ep->flags & EFF_MEM) ? id >= ep->fids : id > ep->fids))
@@ -367,7 +372,7 @@ ef_write(int type, int id, void *from)
 
 /*
  * Extend the file-backed table TYPE by COUNT elements.
- * Return the ID of the first new element, or -1 on failure.
+ * Return non-zero on success, zero on failure.
  */
 int
 ef_extend(int type, int count)