From 5d8cafcf6a47ce73afff06499f6be23c72ab6797 Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Sun, 1 Jul 2018 01:54:14 +0430 Subject: [PATCH] Improve nommap naming and use C style comments on create_from_file (#1084) --- .circleci/config.yml | 2 +- src/hb-blob.cc | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 012873e21..5ad1ae135 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -47,7 +47,7 @@ jobs: - checkout - run: apk update && apk add ragel make pkgconfig libtool autoconf automake gettext gcc g++ glib-dev freetype-dev cairo-dev # C??FLAGS are not needed for a regular build - - run: CFLAGS="-O3" CXXFLAGS="-O3 -DNOMMAPFILEREADER" ./autogen.sh + - run: CFLAGS="-O3" CXXFLAGS="-O3 -DHB_NO_MMAP" ./autogen.sh - run: make - run: make check || .ci/fail.sh diff --git a/src/hb-blob.cc b/src/hb-blob.cc index 10db09785..98e9c65c2 100644 --- a/src/hb-blob.cc +++ b/src/hb-blob.cc @@ -534,9 +534,9 @@ _hb_mapped_file_destroy (hb_mapped_file_t *file) hb_blob_t * hb_blob_create_from_file (const char *file_name) { - // Adopted from glib's gmappedfile.c with Matthias Clasen and - // Allison Lortie permission but changed a lot to suit our need. -#if defined(HAVE_MMAP) && !defined(NOMMAPFILEREADER) + /* Adopted from glib's gmappedfile.c with Matthias Clasen and + Allison Lortie permission but changed a lot to suit our need. */ +#if defined(HAVE_MMAP) && !defined(HB_NO_MMAP) hb_mapped_file_t *file = (hb_mapped_file_t *) calloc (1, sizeof (hb_mapped_file_t)); if (unlikely (!file)) return hb_blob_get_empty (); @@ -563,7 +563,7 @@ fail: fail_without_close: free (file); -#elif (defined(_WIN32) || defined(__CYGWIN__)) && !defined(NOMMAPFILEREADER) +#elif (defined(_WIN32) || defined(__CYGWIN__)) && !defined(HB_NO_MMAP) hb_mapped_file_t *file = (hb_mapped_file_t *) calloc (1, sizeof (hb_mapped_file_t)); if (unlikely (!file)) return hb_blob_get_empty (); @@ -592,8 +592,8 @@ fail_without_close: #endif - // The following tries to read a file without knowing its size beforehand - // It's used as a fallback for systems without mmap or to read from pipes + /* The following tries to read a file without knowing its size beforehand + It's used as a fallback for systems without mmap or to read from pipes */ unsigned long len = 0, allocated = BUFSIZ * 16; char *data = (char *) malloc (allocated); if (unlikely (data == nullptr)) return hb_blob_get_empty (); @@ -606,8 +606,8 @@ fail_without_close: if (allocated - len < BUFSIZ) { allocated *= 2; - // Don't allocate and go more than ~536MB, our mmap reader still - // can cover files like that but lets limit our fallback reader + /* Don't allocate and go more than ~536MB, our mmap reader still + can cover files like that but lets limit our fallback reader */ if (unlikely (allocated > (2 << 28))) goto fread_fail; char *new_data = (char *) realloc (data, allocated); if (unlikely (new_data == nullptr)) goto fread_fail;