lib: Remove unused [un]map_file
authorVolker Lendecke <vl@samba.org>
Sun, 22 Mar 2015 08:50:25 +0000 (09:50 +0100)
committerJeremy Allison <jra@samba.org>
Mon, 23 Mar 2015 23:00:20 +0000 (00:00 +0100)
Reviewed-by: Jeremy Allison <jra@samba.org>
Signed-off-by: Volker Lendecke <vl@samba.org>
lib/util/samba_util.h
lib/util/util_file.c

index 7adcdba11ededfaf2b95bc3c1d34a3e704992e62..69413080c5c4e7a6972ba770f76dd501bc08df23 100644 (file)
@@ -508,11 +508,6 @@ load a file into memory
 **/
 _PUBLIC_ char *file_load(const char *fname, size_t *size, size_t maxsize, TALLOC_CTX *mem_ctx);
 
-/**
-mmap (if possible) or read a file
-**/
-_PUBLIC_ void *map_file(const char *fname, size_t size);
-
 /**
 load a file into memory and return an array of pointers to lines in the file
 must be freed with talloc_free(). 
@@ -801,8 +796,6 @@ bool pm_process( const char *fileName,
                  bool (*pfunc)(const char *, const char *, void *),
                                 void *userdata);
 
-bool unmap_file(void *start, size_t size);
-
 void print_asc(int level, const uint8_t *buf,int len);
 void print_asc_cb(const uint8_t *buf, int len,
                  void (*cb)(const char *buf, void *private_data),
index b9d7bdd9d1f96c74e4f4e58b7857a0664865d67d..1ec3582d5505acc8c02bf1f9ce320f1169868e92 100644 (file)
@@ -211,62 +211,6 @@ _PUBLIC_ char *file_load(const char *fname, size_t *size, size_t maxsize, TALLOC
        return p;
 }
 
-
-/**
-mmap (if possible) or read a file
-**/
-_PUBLIC_ void *map_file(const char *fname, size_t size)
-{
-       size_t s2 = 0;
-       void *p = NULL;
-#ifdef HAVE_MMAP
-       int fd;
-       fd = open(fname, O_RDONLY, 0);
-       if (fd == -1) {
-               DEBUG(2,("Failed to load %s - %s\n", fname, strerror(errno)));
-               return NULL;
-       }
-       p = mmap(NULL, size, PROT_READ, MAP_SHARED|MAP_FILE, fd, 0);
-       close(fd);
-       if (p == MAP_FAILED) {
-               DEBUG(1,("Failed to mmap %s - %s\n", fname, strerror(errno)));
-               return NULL;
-       }
-#endif
-       if (!p) {
-               p = file_load(fname, &s2, 0, NULL);
-               if (!p) return NULL;
-               if (s2 != size) {
-                       DEBUG(1,("incorrect size for %s - got %d expected %d\n",
-                                fname, (int)s2, (int)size));
-                       talloc_free(p);
-                       return NULL;
-               }
-       }
-
-       return p;
-}
-
-/**
- unmap or free memory
-**/
-
-bool unmap_file(void *start, size_t size)
-{
-#ifdef HAVE_MMAP
-       if (munmap( start, size ) != 0) {
-               DEBUG( 1, ("map_file: Failed to unmap address %p "
-                       "of size %u - %s\n",
-                       start, (unsigned int)size, strerror(errno) ));
-               return false;
-       }
-       return true;
-#else
-       talloc_free(start);
-       return true;
-#endif
-}
-
 /**
 parse a buffer into lines
 'p' will be freed on error, and otherwise will be made a child of the returned array