Remove (unused) posix_memalign fallback
authorBehdad Esfahbod <behdad@behdad.org>
Tue, 18 Jun 2019 19:41:56 +0000 (12:41 -0700)
committerBehdad Esfahbod <behdad@behdad.org>
Tue, 18 Jun 2019 19:41:56 +0000 (12:41 -0700)
Was wrong.  The returned pointer couldn't be passed to free().  Ouch!

configure.ac
src/hb.hh

index ade6840..958bd2d 100644 (file)
@@ -77,7 +77,7 @@ GTK_DOC_CHECK([1.15],[--flavour no-tmpl])
 ])
 
 # Functions and headers
-AC_CHECK_FUNCS(atexit mprotect sysconf getpagesize mmap isatty newlocale strtod_l posix_memalign)
+AC_CHECK_FUNCS(atexit mprotect sysconf getpagesize mmap isatty newlocale strtod_l)
 AC_CHECK_HEADERS(unistd.h sys/mman.h xlocale.h stdbool.h)
 
 # Compiler flags
index a2baa31..a63d629 100644 (file)
--- a/src/hb.hh
+++ b/src/hb.hh
@@ -211,14 +211,6 @@ extern "C" void  hb_free_impl(void *ptr);
 #define calloc hb_calloc_impl
 #define realloc hb_realloc_impl
 #define free hb_free_impl
-
-#ifdef hb_memalign_impl
-extern "C" int hb_memalign_impl(void **memptr, size_t alignment, size_t size);
-#define posix_memalign hb_memalign_impl
-#else
-#undef HAVE_POSIX_MEMALIGN
-#endif
-
 #endif
 
 
@@ -515,32 +507,6 @@ typedef uint64_t hb_vector_size_impl_t;
 #define VAR 1
 
 
-/* fallback for posix_memalign() */
-static inline int
-_hb_memalign(void **memptr, size_t alignment, size_t size)
-{
-  if (unlikely (0 != (alignment & (alignment - 1)) ||
-               !alignment ||
-               0 != (alignment & (sizeof (void *) - 1))))
-    return EINVAL;
-
-  char *p = (char *) malloc (size + alignment - 1);
-  if (unlikely (!p))
-    return ENOMEM;
-
-  size_t off = (size_t) p & (alignment - 1);
-  if (off)
-    p += alignment - off;
-
-  *memptr = (void *) p;
-
-  return 0;
-}
-#if !defined(posix_memalign) && !defined(HAVE_POSIX_MEMALIGN)
-#define posix_memalign _hb_memalign
-#endif
-
-
 /*
  * Big-endian integers.  Here because fundamental.
  */