]> git.draconx.ca Git - liblbx.git/commitdiff
liblbx: Remove lbx_mmap.
authorNick Bowler <draconx@users.sourceforge.net>
Mon, 2 Nov 2009 04:49:09 +0000 (23:49 -0500)
committerNick Bowler <nbowler@draconx.ca>
Thu, 4 Feb 2010 01:29:41 +0000 (20:29 -0500)
This interface does not belong in this library, since it is intended to
support reading from data that is not mmap-able.

src/lbx.c
src/lbx.h

index ae0382cfeba1cd799a0199df4a6776972b254fef..fc52680c47c0a57c19fec6a074de4ff0af5f884c 100644 (file)
--- a/src/lbx.c
+++ b/src/lbx.c
@@ -252,39 +252,6 @@ size_t lbx_extract(struct lbx_state *lbx, size_t index, FILE *of)
        return _lbx_fextract(lbx, base, len, of);
 }
 
-void *lbx_mmap(struct lbx_state *lbx, size_t index, size_t *len)
-{
-       unsigned char *mapping;
-       struct stat statbuf;
-       size_t base;
-
-       if (index >= lbx->nfiles) {
-               lbx_errno = LBX_ERANGE;
-               return NULL;
-       }
-       
-       base = lbx->offsets[index];
-       *len = lbx->offsets[index+1] - lbx->offsets[index];
-
-       if (lbx->mem)
-               return lbx->mem + base;
-       
-       if (fstat(fileno(lbx->f), &statbuf) == -1) {
-               lbx_errno = -errno;
-               return NULL;
-       }
-
-       mapping = mmap(NULL, statbuf.st_size, PROT_READ, 0, fileno(lbx->f), 0);
-       if (mapping == MAP_FAILED) {
-               lbx_errno = -errno;
-               return NULL;
-       }
-
-       lbx->mem     = mapping;
-       lbx->memsize = statbuf.st_size;
-       return mapping + base;
-}
-
 int lbx_close(struct lbx_state *lbx)
 {
        int rc = 0;
@@ -292,12 +259,8 @@ int lbx_close(struct lbx_state *lbx)
        if (!lbx)
                return 0;
 
-       if (lbx->f) {
+       if (lbx->f)
                rc = fclose(lbx->f);
-               if (lbx->mem) {
-                       munmap(lbx->mem, lbx->memsize);
-               }
-       }
 
        free(lbx);
        return rc;
index b2a90efa3f212f6f8594d1968b9e681527b2f5c7..89d4bb4201bd31e471374c964524e520be1b4512 100644 (file)
--- a/src/lbx.h
+++ b/src/lbx.h
@@ -30,7 +30,6 @@ size_t lbx_numfiles(LBX *);
 /* File operations */
 int    lbx_stat(LBX *, size_t, struct lbx_statbuf *);
 size_t lbx_extract(LBX *, size_t, FILE *);
-void  *lbx_mmap(LBX *, size_t, size_t *);
 
 /* Misc operations */
 const char *lbx_strerror(void);