From: Nick Bowler Date: Mon, 2 Nov 2009 04:49:09 +0000 (-0500) Subject: liblbx: Remove lbx_mmap. X-Git-Url: http://git.draconx.ca/gitweb/liblbx.git/commitdiff_plain/cc58652bf808568b935ca755d4360aa0f1aedfed liblbx: Remove lbx_mmap. This interface does not belong in this library, since it is intended to support reading from data that is not mmap-able. --- diff --git a/src/lbx.c b/src/lbx.c index ae0382c..fc52680 100644 --- 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; diff --git a/src/lbx.h b/src/lbx.h index b2a90ef..89d4bb4 100644 --- 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);