http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/ink_memory.h
----------------------------------------------------------------------
diff --git a/lib/ts/ink_memory.h b/lib/ts/ink_memory.h
index 7a8729b..69285f0 100644
--- a/lib/ts/ink_memory.h
+++ b/lib/ts/ink_memory.h
@@ -21,7 +21,7 @@
   limitations under the License.
  */
 #ifndef _ink_memory_h_
-#define        _ink_memory_h_
+#define _ink_memory_h_
 
 #include <ctype.h>
 #include <string.h>
@@ -78,46 +78,46 @@
 
 #ifdef __cplusplus
 extern "C" {
-#endif                          /* __cplusplus */
+#endif /* __cplusplus */
 
-  typedef struct iovec IOVec;
+typedef struct iovec IOVec;
 
-  void *  ats_malloc(size_t size);
-  void *  ats_calloc(size_t nelem, size_t elsize);
-  void *  ats_realloc(void *ptr, size_t size);
-  void *  ats_memalign(size_t alignment, size_t size);
-  void    ats_free(void *ptr);
-  void *  ats_free_null(void *ptr);
-  void    ats_memalign_free(void *ptr);
-  int     ats_mallopt(int param, int value);
+void *ats_malloc(size_t size);
+void *ats_calloc(size_t nelem, size_t elsize);
+void *ats_realloc(void *ptr, size_t size);
+void *ats_memalign(size_t alignment, size_t size);
+void ats_free(void *ptr);
+void *ats_free_null(void *ptr);
+void ats_memalign_free(void *ptr);
+int ats_mallopt(int param, int value);
 
-  int     ats_msync(caddr_t addr, size_t len, caddr_t end, int flags);
-  int     ats_madvise(caddr_t addr, size_t len, int flags);
-  int     ats_mlock(caddr_t addr, size_t len);
+int ats_msync(caddr_t addr, size_t len, caddr_t end, int flags);
+int ats_madvise(caddr_t addr, size_t len, int flags);
+int ats_mlock(caddr_t addr, size_t len);
 
-  static inline size_t __attribute__((const)) ats_pagesize(void)
-  {
-    static size_t page_size;
+static inline size_t __attribute__((const)) ats_pagesize(void)
+{
+  static size_t page_size;
 
-    if (page_size)
-      return page_size;
+  if (page_size)
+    return page_size;
 
 #if defined(HAVE_SYSCONF) && defined(_SC_PAGESIZE)
-    page_size = (size_t)sysconf(_SC_PAGESIZE);
+  page_size = (size_t)sysconf(_SC_PAGESIZE);
 #elif defined(HAVE_GETPAGESIZE)
-    page_size = (size_t)getpagesize()
+  page_size = (size_t)getpagesize()
 #else
-    page_size = (size_t)8192;
+  page_size = (size_t)8192;
 #endif
 
-    return page_size;
-  }
+  return page_size;
+}
 
 /* Some convenience wrappers around strdup() functionality */
 char *_xstrdup(const char *str, int length, const char *path);
 
-#define ats_strdup(p)        _xstrdup((p), -1, NULL)
-#define ats_strndup(p,n)     _xstrdup((p), n, NULL)
+#define ats_strdup(p) _xstrdup((p), -1, NULL)
+#define ats_strndup(p, n) _xstrdup((p), n, NULL)
 
 #ifdef __cplusplus
 }
@@ -127,15 +127,15 @@ char *_xstrdup(const char *str, int length, const char 
*path);
 
 template <typename PtrType, typename SizeType>
 static inline IOVec
-make_iovec(PtrType ptr, SizeType sz) {
-  IOVec iov = { ptr, static_cast<size_t>(sz) };
+make_iovec(PtrType ptr, SizeType sz)
+{
+  IOVec iov = {ptr, static_cast<size_t>(sz)};
   return iov;
 }
 
-template <typename PtrType, unsigned N>
-static inline IOVec
-make_iovec(PtrType (&array)[N]) {
-  IOVec iov = { &array[0], static_cast<size_t>(sizeof(array)) };
+template <typename PtrType, unsigned N> static inline IOVec 
make_iovec(PtrType(&array)[N])
+{
+  IOVec iov = {&array[0], static_cast<size_t>(sizeof(array))};
   return iov;
 }
 
@@ -166,8 +166,10 @@ make_iovec(PtrType (&array)[N]) {
     @endcode
 
  */
-template < typename T > inline void
-ink_zero(T& t) {
+template <typename T>
+inline void
+ink_zero(T &t)
+{
   memset(&t, 0, sizeof(t));
 }
 
@@ -232,18 +234,16 @@ ink_zero(T& t) {
 
 */
 
-template <
-  typename TRAITS ///< Traits object.
->
+template <typename TRAITS ///< Traits object.
+          >
 class ats_scoped_resource
 {
 public:
-  typedef TRAITS Traits; ///< Make template arg available.
+  typedef TRAITS Traits;                          ///< Make template arg 
available.
   typedef typename TRAITS::value_type value_type; ///< Import value type.
-  typedef ats_scoped_resource self; ///< Self reference type.
+  typedef ats_scoped_resource self;               ///< Self reference type.
 
 public:
-
   /// Default constructor - an empty container.
   ats_scoped_resource() : _r(Traits::initValue()) {}
 
@@ -251,19 +251,20 @@ public:
   explicit ats_scoped_resource(value_type rt) : _r(rt) {}
 
   /// Destructor.
-  ~ats_scoped_resource() {
+  ~ats_scoped_resource()
+  {
     if (Traits::isValid(_r))
       Traits::destroy(_r);
   }
 
   /// Automatic conversion to resource type.
-  operator value_type () const {
-    return _r;
-  }
+  operator value_type() const { return _r; }
   /// Explicit conversion to resource type.
   /// @note Syntactic sugar for @c static_cast<value_type>(instance). Required 
when passing to var arg function
   /// as automatic conversion won't be done.
-  value_type get() const {
+  value_type
+  get() const
+  {
     return _r;
   }
 
@@ -279,7 +280,9 @@ public:
 
       @return The no longer contained resource.
   */
-  value_type release() {
+  value_type
+  release()
+  {
     value_type zret = _r;
     _r = Traits::initValue();
     return zret;
@@ -291,45 +294,56 @@ public:
 
       @internal This is usually overridden in subclasses to get the return 
type adjusted.
   */
-  self& operator = (value_type rt) {
-    if (Traits::isValid(_r)) Traits::destroy(_r);
+  self &operator=(value_type rt)
+  {
+    if (Traits::isValid(_r))
+      Traits::destroy(_r);
     _r = rt;
     return *this;
   }
 
   /// Equality.
-  bool operator == (value_type rt) const {
-    return _r == rt;
-  }
+  bool operator==(value_type rt) const { return _r == rt; }
 
   /// Inequality.
-  bool operator != (value_type rt) const {
-    return _r != rt;
-  }
+  bool operator!=(value_type rt) const { return _r != rt; }
 
   /// Test if the contained resource is valid.
-  bool isValid() const {
+  bool
+  isValid() const
+  {
     return Traits::isValid(_r);
   }
 
 protected:
   value_type _r; ///< Resource.
 private:
-  ats_scoped_resource(self const&); ///< Copy constructor not permitted.
-  self& operator = (self const&); ///< Self assignment not permitted.
-
+  ats_scoped_resource(self const &); ///< Copy constructor not permitted.
+  self &operator=(self const &);     ///< Self assignment not permitted.
 };
 
-namespace detail {
+namespace detail
+{
 /** Traits for @c ats_scoped_resource for file descriptors.
  */
-  struct SCOPED_FD_TRAITS
+struct SCOPED_FD_TRAITS {
+  typedef int value_type;
+  static int
+  initValue()
+  {
+    return -1;
+  }
+  static bool
+  isValid(int fd)
   {
-    typedef int value_type;
-    static int initValue() { return -1; }
-    static bool isValid(int fd) { return fd >= 0; }
-    static void destroy(int fd) { close(fd); }
-  };
+    return fd >= 0;
+  }
+  static void
+  destroy(int fd)
+  {
+    close(fd);
+  }
+};
 }
 /** File descriptor as a scoped resource.
  */
@@ -337,7 +351,7 @@ class ats_scoped_fd : public 
ats_scoped_resource<detail::SCOPED_FD_TRAITS>
 {
 public:
   typedef ats_scoped_resource<detail::SCOPED_FD_TRAITS> super; ///< Super type.
-  typedef ats_scoped_fd self; ///< Self reference type.
+  typedef ats_scoped_fd self;                                  ///< Self 
reference type.
 
   /// Default constructor - an empty container.
   ats_scoped_fd() : super() {}
@@ -349,38 +363,59 @@ public:
       Any resource currently contained is destroyed.
       This object becomes the owner of @a rt.
   */
-  self& operator = (value_type rt) {
+  self &operator=(value_type rt)
+  {
     super::operator=(rt);
     return *this;
   }
-
 };
 
-namespace detail {
+namespace detail
+{
 /** Traits for @c ats_scoped_resource for pointers from @c ats_malloc.
  */
-  template <
-    typename T ///< Underlying type (not the pointer type).
-  >
-  struct SCOPED_MALLOC_TRAITS
+template <typename T ///< Underlying type (not the pointer type).
+          >
+struct SCOPED_MALLOC_TRAITS {
+  typedef T *value_type;
+  static T *
+  initValue()
+  {
+    return NULL;
+  }
+  static bool
+  isValid(T *t)
+  {
+    return 0 != t;
+  }
+  static void
+  destroy(T *t)
+  {
+    ats_free(t);
+  }
+};
+
+/// Traits for @c ats_scoped_resource for objects using @c new and @c delete.
+template <typename T ///< Underlying type - not the pointer type.
+          >
+struct SCOPED_OBJECT_TRAITS {
+  typedef T *value_type;
+  static T *
+  initValue()
   {
-    typedef T* value_type;
-    static T*  initValue() { return NULL; }
-    static bool isValid(T* t) { return 0 != t; }
-    static void destroy(T* t) { ats_free(t); }
-  };
-
-  /// Traits for @c ats_scoped_resource for objects using @c new and @c delete.
-  template <
-    typename T ///< Underlying type - not the pointer type.
-  >
-  struct SCOPED_OBJECT_TRAITS
+    return NULL;
+  }
+  static bool
+  isValid(T *t)
   {
-    typedef T* value_type;
-    static T* initValue() { return NULL; }
-    static bool isValid(T* t) { return 0 != t; }
-    static void destroy(T* t) { delete t; }
-  };
+    return 0 != t;
+  }
+  static void
+  destroy(T *t)
+  {
+    delete t;
+  }
+};
 }
 
 /** Specialization of @c ats_scoped_resource for strings.
@@ -388,21 +423,19 @@ namespace detail {
 */
 class ats_scoped_str : public 
ats_scoped_resource<detail::SCOPED_MALLOC_TRAITS<char> >
 {
- public:
+public:
   typedef ats_scoped_resource<detail::SCOPED_MALLOC_TRAITS<char> > super; ///< 
Super type.
-  typedef ats_scoped_str self; ///< Self reference type.
+  typedef ats_scoped_str self;                                            ///< 
Self reference type.
 
   /// Default constructor (no string).
-  ats_scoped_str()
-  { }
+  ats_scoped_str() {}
   /// Construct and allocate @a n bytes for a string.
-  explicit ats_scoped_str(size_t n) : super(static_cast<char*>(ats_malloc(n)))
-  { }
+  explicit ats_scoped_str(size_t n) : super(static_cast<char 
*>(ats_malloc(n))) {}
   /// Put string @a s in this container for cleanup.
-  explicit ats_scoped_str(char* s) : super(s)
-  { }
+  explicit ats_scoped_str(char *s) : super(s) {}
   /// Assign a string @a s to this container.
-  self& operator = (char* s) {
+  self &operator=(char *s)
+  {
     super::operator=(s);
     return *this;
   }
@@ -410,16 +443,16 @@ class ats_scoped_str : public 
ats_scoped_resource<detail::SCOPED_MALLOC_TRAITS<c
 
 /** Specialization of @c ats_scoped_resource for pointers allocated with @c 
ats_malloc.
  */
-template <
-  typename T ///< Underlying (not pointer) type.
->
+template <typename T ///< Underlying (not pointer) type.
+          >
 class ats_scoped_mem : public 
ats_scoped_resource<detail::SCOPED_MALLOC_TRAITS<T> >
 {
 public:
   typedef ats_scoped_resource<detail::SCOPED_MALLOC_TRAITS<T> > super; ///< 
Super type.
-  typedef ats_scoped_mem self; ///< Self reference.
+  typedef ats_scoped_mem self;                                         ///< 
Self reference.
 
-  self& operator = (T* ptr) {
+  self &operator=(T *ptr)
+  {
     super::operator=(ptr);
     return *this;
   }
@@ -429,29 +462,27 @@ public:
     This handles a pointer to an object created by @c new and destroyed by @c 
delete.
 */
 
-template <
-  typename T /// Underlying (not pointer) type.
->
+template <typename T /// Underlying (not pointer) type.
+          >
 class ats_scoped_obj : public 
ats_scoped_resource<detail::SCOPED_OBJECT_TRAITS<T> >
 {
 public:
   typedef ats_scoped_resource<detail::SCOPED_OBJECT_TRAITS<T> > super; ///< 
Super type.
-  typedef ats_scoped_obj self; ///< Self reference.
+  typedef ats_scoped_obj self;                                         ///< 
Self reference.
 
   /// Default constructor - an empty container.
   ats_scoped_obj() : super() {}
 
   /// Construct with contained resource.
-  explicit ats_scoped_obj(T* obj) : super(obj) {}
+  explicit ats_scoped_obj(T *obj) : super(obj) {}
 
-  self& operator = (T* obj) {
+  self &operator=(T *obj)
+  {
     super::operator=(obj);
     return *this;
   }
 
-  T* operator -> () const {
-    return *this;
-  }
+  T *operator->() const { return *this; }
 };
 
 /** Combine two strings as file paths.
@@ -459,25 +490,27 @@ public:
      are handled to yield exactly one separator.
      @return A newly @x ats_malloc string of the combined paths.
 */
-inline char*
-path_join (ats_scoped_str const& lhs, ats_scoped_str  const& rhs)
+inline char *
+path_join(ats_scoped_str const &lhs, ats_scoped_str const &rhs)
 {
   size_t ln = strlen(lhs);
   size_t rn = strlen(rhs);
-  char const* rptr = rhs; // May need to be modified.
+  char const *rptr = rhs; // May need to be modified.
 
-  if (ln && lhs[ln-1] == '/') --ln; // drop trailing separator.
-  if (rn && *rptr == '/') --rn, ++rptr; // drop leading separator.
+  if (ln && lhs[ln - 1] == '/')
+    --ln; // drop trailing separator.
+  if (rn && *rptr == '/')
+    --rn, ++rptr; // drop leading separator.
 
   ats_scoped_str x(ln + rn + 2);
 
   memcpy(x, lhs, ln);
   x[ln] = '/';
-  memcpy(x + ln + 1,  rptr, rn);
-  x[ln+rn+1] = 0; // terminate string.
+  memcpy(x + ln + 1, rptr, rn);
+  x[ln + rn + 1] = 0; // terminate string.
 
   return x.release();
 }
-#endif  /* __cplusplus */
+#endif /* __cplusplus */
 
 #endif

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/ink_mutex.h
----------------------------------------------------------------------
diff --git a/lib/ts/ink_mutex.h b/lib/ts/ink_mutex.h
index bc84da4..7603627 100644
--- a/lib/ts/ink_mutex.h
+++ b/lib/ts/ink_mutex.h
@@ -49,12 +49,9 @@ class x_pthread_mutexattr_t
 public:
   pthread_mutexattr_t attr;
   x_pthread_mutexattr_t();
-  ~x_pthread_mutexattr_t()
-  {
-  }
+  ~x_pthread_mutexattr_t() {}
 };
-inline
-x_pthread_mutexattr_t::x_pthread_mutexattr_t()
+inline x_pthread_mutexattr_t::x_pthread_mutexattr_t()
 {
   pthread_mutexattr_init(&attr);
 #ifndef POSIX_THREAD_10031c
@@ -65,12 +62,12 @@ x_pthread_mutexattr_t::x_pthread_mutexattr_t()
 extern class x_pthread_mutexattr_t _g_mattr;
 
 static inline int
-ink_mutex_init(ink_mutex * m, const char *name)
+ink_mutex_init(ink_mutex *m, const char *name)
 {
-  (void) name;
+  (void)name;
 
 #if defined(solaris)
-  if ( pthread_mutex_init(m, NULL) != 0 ) {
+  if (pthread_mutex_init(m, NULL) != 0) {
     abort();
   }
 #else
@@ -82,13 +79,13 @@ ink_mutex_init(ink_mutex * m, const char *name)
 }
 
 static inline int
-ink_mutex_destroy(ink_mutex * m)
+ink_mutex_destroy(ink_mutex *m)
 {
   return pthread_mutex_destroy(m);
 }
 
 static inline int
-ink_mutex_acquire(ink_mutex * m)
+ink_mutex_acquire(ink_mutex *m)
 {
   if (pthread_mutex_lock(m) != 0) {
     abort();
@@ -97,7 +94,7 @@ ink_mutex_acquire(ink_mutex * m)
 }
 
 static inline int
-ink_mutex_release(ink_mutex * m)
+ink_mutex_release(ink_mutex *m)
 {
   if (pthread_mutex_unlock(m) != 0) {
     abort();
@@ -106,7 +103,7 @@ ink_mutex_release(ink_mutex * m)
 }
 
 static inline int
-ink_mutex_try_acquire(ink_mutex * m)
+ink_mutex_try_acquire(ink_mutex *m)
 {
   return pthread_mutex_trylock(m) == 0;
 }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/ink_platform.h
----------------------------------------------------------------------
diff --git a/lib/ts/ink_platform.h b/lib/ts/ink_platform.h
index 35eba59..251efe0 100644
--- a/lib/ts/ink_platform.h
+++ b/lib/ts/ink_platform.h
@@ -30,27 +30,27 @@
 #include <stdio.h>
 #include <stdarg.h>
 #ifdef HAVE_STDLIB_H
-# include <stdlib.h>
+#include <stdlib.h>
 #endif
 #include <ctype.h>
 #ifdef HAVE_STRING_H
-# include <string.h>
+#include <string.h>
 #endif
 #ifdef HAVE_STRINGS_H
-# include <strings.h>
+#include <strings.h>
 #endif
 #include <errno.h>
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #endif
 #ifdef HAVE_SYS_STAT_H
-# include <sys/stat.h>
+#include <sys/stat.h>
 #endif
 #include <fcntl.h>
 
 #include <limits.h>
 #ifdef HAVE_UNISTD_H
-# include <unistd.h>
+#include <unistd.h>
 #endif
 #include <sys/stat.h>
 #include <assert.h>
@@ -72,39 +72,39 @@
 #include <sys/mman.h>
 
 #ifdef HAVE_NETINET_IN_H
-# include <netinet/in.h>
+#include <netinet/in.h>
 #endif
 #ifdef HAVE_NETINET_IN_SYSTM_H
-# include <netinet/in_systm.h>
+#include <netinet/in_systm.h>
 #endif
 #ifdef HAVE_NETINET_TCP_H
-# include <netinet/tcp.h>
+#include <netinet/tcp.h>
 #endif
 #ifdef HAVE_NETINET_IP_H
-# include <netinet/ip.h>
+#include <netinet/ip.h>
 #endif
 #ifdef HAVE_NETINET_IP_ICMP_H
-# include <netinet/ip_icmp.h>
+#include <netinet/ip_icmp.h>
 #endif
 #ifdef HAVE_NETDB_H
-# include <netdb.h>
+#include <netdb.h>
 #endif
 #ifdef HAVE_ARPA_INET_H
-# include <arpa/inet.h>
+#include <arpa/inet.h>
 #endif
 #ifdef HAVE_ARPA_NAMESER_H
-# include <arpa/nameser.h>
+#include <arpa/nameser.h>
 #endif
 #ifdef HAVE_ARPA_NAMESER_COMPAT_H
-# include <arpa/nameser_compat.h>
+#include <arpa/nameser_compat.h>
 #endif
 
 #include <signal.h>
 #ifdef HAVE_SIGINFO_H
-# include <siginfo.h>
+#include <siginfo.h>
 #endif
 #ifdef HAVE_WAIT_H
-# include <wait.h>
+#include <wait.h>
 #endif
 
 #include <syslog.h>
@@ -123,17 +123,17 @@
 
 
 #ifdef HAVE_VALUES_H
-# include <values.h>
+#include <values.h>
 #endif
 #ifdef HAVE_ALLOCA_H
-# include <alloca.h>
+#include <alloca.h>
 #endif
 
 #include <errno.h>
 #include <dirent.h>
 
 #ifdef HAVE_CPIO_H
-# include <cpio.h>
+#include <cpio.h>
 #endif
 
 struct ifafilt;
@@ -152,20 +152,20 @@ struct ifafilt;
 #endif
 
 #ifdef HAVE_MACHINE_ENDIAN_H
-# include <machine/endian.h>
+#include <machine/endian.h>
 #endif
 #ifdef HAVE_ENDIAN_H
-# include <endian.h>
+#include <endian.h>
 #endif
 #ifdef HAVE_SYS_BYTEORDER_H
-# include <sys/byteorder.h>
+#include <sys/byteorder.h>
 #endif
 
 #ifdef HAVE_SYS_IOCTL_H
-# include <sys/ioctl.h>
+#include <sys/ioctl.h>
 #endif
 #ifdef HAVE_SYS_SOCKIO_H
-# include <sys/sockio.h>
+#include <sys/sockio.h>
 #endif
 
 #include <resolv.h>
@@ -176,30 +176,30 @@ typedef unsigned int in_addr_t;
 #endif
 
 #ifdef HAVE_SYS_SYSINFO_H
-# include <sys/sysinfo.h>
+#include <sys/sysinfo.h>
 #endif
 
 #if !defined(darwin)
-# ifdef HAVE_SYS_SYSCTL_H
-#  include <sys/sysctl.h>
-# endif
+#ifdef HAVE_SYS_SYSCTL_H
+#include <sys/sysctl.h>
+#endif
 #endif
 #ifdef HAVE_SYS_SYSTEMINFO_H
-# include <sys/systeminfo.h>
+#include <sys/systeminfo.h>
 #endif
 
 #ifdef HAVE_DLFCN_H
-# include <dlfcn.h>
+#include <dlfcn.h>
 #endif
 #ifdef HAVE_MATH_H
-# include <math.h>
+#include <math.h>
 #endif
 #ifdef HAVE_FLOAT_H
-# include <float.h>
+#include <float.h>
 #endif
 
 #ifdef HAVE_SYS_SYSMACROS_H
-# include <sys/sysmacros.h>
+#include <sys/sysmacros.h>
 #endif
 
 #ifdef HAVE_SYS_PRCTL_H

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/ink_queue.cc
----------------------------------------------------------------------
diff --git a/lib/ts/ink_queue.cc b/lib/ts/ink_queue.cc
index 6286d8e..e718b3f 100644
--- a/lib/ts/ink_queue.cc
+++ b/lib/ts/ink_queue.cc
@@ -67,7 +67,7 @@ inkcoreapi volatile int64_t fastalloc_mem_total = 0;
 
 // #define MEMPROTECT 1
 
-#define MEMPROTECT_SIZE  0x200
+#define MEMPROTECT_SIZE 0x200
 
 #ifdef MEMPROTECT
 static const int page_size = ats_pagesize();
@@ -77,12 +77,10 @@ ink_freelist_list *freelists = NULL;
 
 inkcoreapi volatile int64_t freelist_allocated_mem = 0;
 
-#define fl_memadd(_x_) \
-   ink_atomic_increment(&freelist_allocated_mem, (int64_t) (_x_));
+#define fl_memadd(_x_) ink_atomic_increment(&freelist_allocated_mem, 
(int64_t)(_x_));
 
 void
-ink_freelist_init(InkFreeList **fl, const char *name, uint32_t type_size,
-                  uint32_t chunk_size, uint32_t alignment)
+ink_freelist_init(InkFreeList **fl, const char *name, uint32_t type_size, 
uint32_t chunk_size, uint32_t alignment)
 {
 #if TS_USE_RECLAIMABLE_FREELIST
   return reclaimable_freelist_init(fl, name, type_size, chunk_size, alignment);
@@ -117,7 +115,8 @@ ink_freelist_init(InkFreeList **fl, const char *name, 
uint32_t type_size,
 }
 
 void
-ink_freelist_madvise_init(InkFreeList **fl, const char *name, uint32_t 
type_size, uint32_t chunk_size, uint32_t alignment, int advice)
+ink_freelist_madvise_init(InkFreeList **fl, const char *name, uint32_t 
type_size, uint32_t chunk_size, uint32_t alignment,
+                          int advice)
 {
   ink_freelist_init(fl, name, type_size, chunk_size, alignment);
 #if TS_USE_RECLAIMABLE_FREELIST
@@ -128,8 +127,7 @@ ink_freelist_madvise_init(InkFreeList **fl, const char 
*name, uint32_t type_size
 }
 
 InkFreeList *
-ink_freelist_create(const char *name, uint32_t type_size, uint32_t chunk_size,
-                    uint32_t alignment)
+ink_freelist_create(const char *name, uint32_t type_size, uint32_t chunk_size, 
uint32_t alignment)
 {
   InkFreeList *f;
 
@@ -145,7 +143,7 @@ int fake_global_for_ink_queue = 0;
 
 int fastmemtotal = 0;
 void *
-ink_freelist_new(InkFreeList * f)
+ink_freelist_new(InkFreeList *f)
 {
 #if TS_USE_FREELIST
 #if TS_USE_RECLAIMABLE_FREELIST
@@ -171,7 +169,7 @@ ink_freelist_new(InkFreeList * f)
 
       void *newp = NULL;
 #ifdef DEBUG
-      char *oldsbrk = (char *) sbrk(0), *newsbrk = NULL;
+      char *oldsbrk = (char *)sbrk(0), *newsbrk = NULL;
 #endif
       if (f->alignment)
         newp = ats_memalign(f->alignment, f->chunk_size * type_size);
@@ -181,21 +179,21 @@ ink_freelist_new(InkFreeList * f)
 
       fl_memadd(f->chunk_size * type_size);
 #ifdef DEBUG
-      newsbrk = (char *) sbrk(0);
+      newsbrk = (char *)sbrk(0);
       ink_atomic_increment(&fastmemtotal, newsbrk - oldsbrk);
-      /*      printf("fastmem %d, %d, %d\n", f->chunk_size * type_size,
-         newsbrk - oldsbrk, fastmemtotal); */
+/*      printf("fastmem %d, %d, %d\n", f->chunk_size * type_size,
+   newsbrk - oldsbrk, fastmemtotal); */
 #endif
       SET_FREELIST_POINTER_VERSION(item, newp, 0);
 
-      ink_atomic_increment((int *) &f->allocated, f->chunk_size);
-      ink_atomic_increment(&fastalloc_mem_total, (int64_t) f->chunk_size * 
f->type_size);
+      ink_atomic_increment((int *)&f->allocated, f->chunk_size);
+      ink_atomic_increment(&fastalloc_mem_total, (int64_t)f->chunk_size * 
f->type_size);
 
       /* free each of the new elements */
       for (i = 0; i < f->chunk_size; i++) {
-        char *a = ((char *) FREELIST_POINTER(item)) + i * type_size;
+        char *a = ((char *)FREELIST_POINTER(item)) + i * type_size;
 #ifdef DEADBEEF
-        const char str[4] = { (char) 0xde, (char) 0xad, (char) 0xbe, (char) 
0xef };
+        const char str[4] = {(char)0xde, (char)0xad, (char)0xbe, (char)0xef};
         for (int j = 0; j < (int)type_size; j++)
           a[j] = str[j % 4];
 #endif
@@ -207,42 +205,38 @@ ink_freelist_new(InkFreeList * f)
             perror("mprotect");
         }
 #endif /* MEMPROTECT */
-
       }
-      ink_atomic_increment((int *) &f->used, f->chunk_size);
-      ink_atomic_increment(&fastalloc_mem_in_use, (int64_t) f->chunk_size * 
f->type_size);
+      ink_atomic_increment((int *)&f->used, f->chunk_size);
+      ink_atomic_increment(&fastalloc_mem_in_use, (int64_t)f->chunk_size * 
f->type_size);
 
     } else {
-      SET_FREELIST_POINTER_VERSION(next, 
*ADDRESS_OF_NEXT(TO_PTR(FREELIST_POINTER(item)), 0),
-                                   FREELIST_VERSION(item) + 1);
+      SET_FREELIST_POINTER_VERSION(next, 
*ADDRESS_OF_NEXT(TO_PTR(FREELIST_POINTER(item)), 0), FREELIST_VERSION(item) + 
1);
 #if TS_HAS_128BIT_CAS
-       result = ink_atomic_cas((__int128_t*)&f->head.data, item.data, 
next.data);
+      result = ink_atomic_cas((__int128_t *)&f->head.data, item.data, 
next.data);
 #else
-       result = ink_atomic_cas((int64_t *) & f->head.data, item.data, 
next.data);
+      result = ink_atomic_cas((int64_t *)&f->head.data, item.data, next.data);
 #endif
 
 #ifdef SANITY
       if (result) {
         if (FREELIST_POINTER(item) == TO_PTR(FREELIST_POINTER(next)))
           ink_fatal("ink_freelist_new: loop detected");
-        if (((uintptr_t) (TO_PTR(FREELIST_POINTER(next)))) & 3)
+        if (((uintptr_t)(TO_PTR(FREELIST_POINTER(next)))) & 3)
           ink_fatal("ink_freelist_new: bad list");
         if (TO_PTR(FREELIST_POINTER(next)))
-          fake_global_for_ink_queue = *(int *) TO_PTR(FREELIST_POINTER(next));
+          fake_global_for_ink_queue = *(int *)TO_PTR(FREELIST_POINTER(next));
       }
 #endif /* SANITY */
-
     }
-  }
-  while (result == 0);
-  
ink_assert(!((uintptr_t)TO_PTR(FREELIST_POINTER(item))&(((uintptr_t)f->alignment)-1)));
+  } while (result == 0);
+  ink_assert(!((uintptr_t)TO_PTR(FREELIST_POINTER(item)) & 
(((uintptr_t)f->alignment) - 1)));
 
-  ink_atomic_increment((int *) &f->used, 1);
-  ink_atomic_increment(&fastalloc_mem_in_use, (int64_t) f->type_size);
+  ink_atomic_increment((int *)&f->used, 1);
+  ink_atomic_increment(&fastalloc_mem_in_use, (int64_t)f->type_size);
 
   return TO_PTR(FREELIST_POINTER(item));
 #endif /* TS_USE_RECLAIMABLE_FREELIST */
-#else // ! TS_USE_FREELIST
+#else  // ! TS_USE_FREELIST
   void *newp = NULL;
 
   if (f->alignment)
@@ -255,26 +249,26 @@ ink_freelist_new(InkFreeList * f)
 }
 
 void
-ink_freelist_free(InkFreeList * f, void *item)
+ink_freelist_free(InkFreeList *f, void *item)
 {
 #if TS_USE_FREELIST
 #if TS_USE_RECLAIMABLE_FREELIST
   return reclaimable_freelist_free(f, item);
 #else
-  volatile void **adr_of_next = (volatile void **) ADDRESS_OF_NEXT(item, 0);
+  volatile void **adr_of_next = (volatile void **)ADDRESS_OF_NEXT(item, 0);
   head_p h;
   head_p item_pair;
   int result = 0;
 
-  // ink_assert(!((long)item&(f->alignment-1))); XXX - why is this no longer 
working? -bcall
+// ink_assert(!((long)item&(f->alignment-1))); XXX - why is this no longer 
working? -bcall
 
 #ifdef DEADBEEF
   {
-    static const char str[4] = { (char) 0xde, (char) 0xad, (char) 0xbe, (char) 
0xef };
+    static const char str[4] = {(char)0xde, (char)0xad, (char)0xbe, 
(char)0xef};
 
     // set the entire item to DEADBEEF
     for (int j = 0; j < (int)f->type_size; j++)
-      ((char*)item)[j] = str[j % 4];
+      ((char *)item)[j] = str[j % 4];
   }
 #endif /* DEADBEEF */
 
@@ -283,23 +277,23 @@ ink_freelist_free(InkFreeList * f, void *item)
 #ifdef SANITY
     if (TO_PTR(FREELIST_POINTER(h)) == item)
       ink_fatal("ink_freelist_free: trying to free item twice");
-    if (((uintptr_t) (TO_PTR(FREELIST_POINTER(h)))) & 3)
+    if (((uintptr_t)(TO_PTR(FREELIST_POINTER(h)))) & 3)
       ink_fatal("ink_freelist_free: bad list");
     if (TO_PTR(FREELIST_POINTER(h)))
-      fake_global_for_ink_queue = *(int *) TO_PTR(FREELIST_POINTER(h));
+      fake_global_for_ink_queue = *(int *)TO_PTR(FREELIST_POINTER(h));
 #endif /* SANITY */
     *adr_of_next = FREELIST_POINTER(h);
     SET_FREELIST_POINTER_VERSION(item_pair, FROM_PTR(item), 
FREELIST_VERSION(h));
     INK_MEMORY_BARRIER;
 #if TS_HAS_128BIT_CAS
-       result = ink_atomic_cas((__int128_t*) & f->head, h.data, 
item_pair.data);
+    result = ink_atomic_cas((__int128_t *)&f->head, h.data, item_pair.data);
 #else
-       result = ink_atomic_cas((int64_t *) & f->head, h.data, item_pair.data);
+    result = ink_atomic_cas((int64_t *)&f->head, h.data, item_pair.data);
 #endif
   }
 
-  ink_atomic_increment((int *) &f->used, -1);
-  ink_atomic_increment(&fastalloc_mem_in_use, -(int64_t) f->type_size);
+  ink_atomic_increment((int *)&f->used, -1);
+  ink_atomic_increment(&fastalloc_mem_in_use, -(int64_t)f->type_size);
 #endif /* TS_USE_RECLAIMABLE_FREELIST */
 #else
   if (f->alignment)
@@ -314,23 +308,23 @@ ink_freelist_free_bulk(InkFreeList *f, void *head, void 
*tail, size_t num_item)
 {
 #if TS_USE_FREELIST
 #if !TS_USE_RECLAIMABLE_FREELIST
-  volatile void **adr_of_next = (volatile void **) ADDRESS_OF_NEXT(tail, 0);
+  volatile void **adr_of_next = (volatile void **)ADDRESS_OF_NEXT(tail, 0);
   head_p h;
   head_p item_pair;
   int result = 0;
 
-  // ink_assert(!((long)item&(f->alignment-1))); XXX - why is this no longer 
working? -bcall
+// ink_assert(!((long)item&(f->alignment-1))); XXX - why is this no longer 
working? -bcall
 
 #ifdef DEADBEEF
   {
-    static const char str[4] = { (char) 0xde, (char) 0xad, (char) 0xbe, (char) 
0xef };
+    static const char str[4] = {(char)0xde, (char)0xad, (char)0xbe, 
(char)0xef};
 
     // set the entire item to DEADBEEF;
-    void* temp = head;
-    for (size_t i = 0; i<num_item; i++) {
-      for (int j = sizeof(void*); j < (int)f->type_size; j++)
-        ((char*)temp)[j] = str[j % 4];
-      *ADDRESS_OF_NEXT(temp, 0) = FROM_PTR(*ADDRESS_OF_NEXT(temp,0));
+    void *temp = head;
+    for (size_t i = 0; i < num_item; i++) {
+      for (int j = sizeof(void *); j < (int)f->type_size; j++)
+        ((char *)temp)[j] = str[j % 4];
+      *ADDRESS_OF_NEXT(temp, 0) = FROM_PTR(*ADDRESS_OF_NEXT(temp, 0));
       temp = TO_PTR(*ADDRESS_OF_NEXT(temp, 0));
     }
   }
@@ -341,32 +335,32 @@ ink_freelist_free_bulk(InkFreeList *f, void *head, void 
*tail, size_t num_item)
 #ifdef SANITY
     if (TO_PTR(FREELIST_POINTER(h)) == head)
       ink_fatal("ink_freelist_free: trying to free item twice");
-    if (((uintptr_t) (TO_PTR(FREELIST_POINTER(h)))) & 3)
+    if (((uintptr_t)(TO_PTR(FREELIST_POINTER(h)))) & 3)
       ink_fatal("ink_freelist_free: bad list");
     if (TO_PTR(FREELIST_POINTER(h)))
-      fake_global_for_ink_queue = *(int *) TO_PTR(FREELIST_POINTER(h));
+      fake_global_for_ink_queue = *(int *)TO_PTR(FREELIST_POINTER(h));
 #endif /* SANITY */
     *adr_of_next = FREELIST_POINTER(h);
     SET_FREELIST_POINTER_VERSION(item_pair, FROM_PTR(head), 
FREELIST_VERSION(h));
     INK_MEMORY_BARRIER;
 #if TS_HAS_128BIT_CAS
-       result = ink_atomic_cas((__int128_t*) & f->head, h.data, 
item_pair.data);
-#else /* !TS_HAS_128BIT_CAS */
-       result = ink_atomic_cas((int64_t *) & f->head, h.data, item_pair.data);
+    result = ink_atomic_cas((__int128_t *)&f->head, h.data, item_pair.data);
+#else  /* !TS_HAS_128BIT_CAS */
+    result = ink_atomic_cas((int64_t *)&f->head, h.data, item_pair.data);
 #endif /* TS_HAS_128BIT_CAS */
   }
 
-  ink_atomic_increment((int *) &f->used, -1 * num_item);
-  ink_atomic_increment(&fastalloc_mem_in_use, -(int64_t) f->type_size * 
num_item);
-#else /* TS_USE_RECLAIMABLE_FREELIST */
+  ink_atomic_increment((int *)&f->used, -1 * num_item);
+  ink_atomic_increment(&fastalloc_mem_in_use, -(int64_t)f->type_size * 
num_item);
+#else  /* TS_USE_RECLAIMABLE_FREELIST */
   // Avoid compiler warnings
   (void)f;
   (void)head;
   (void)tail;
   (void)num_item;
 #endif /* !TS_USE_RECLAIMABLE_FREELIST */
-#else /* !TS_USE_FREELIST */
-  void * item = head;
+#else  /* !TS_USE_FREELIST */
+  void *item = head;
 
   // Avoid compiler warnings
   (void)tail;
@@ -395,12 +389,12 @@ ink_freelists_snap_baseline()
     fll = fll->next;
   }
 #else // ! TS_USE_FREELIST
-  // TODO?
+// TODO?
 #endif
 }
 
 void
-ink_freelists_dump_baselinerel(FILE * f)
+ink_freelists_dump_baselinerel(FILE *f)
 {
 #if TS_USE_FREELIST
   ink_freelist_list *fll;
@@ -417,8 +411,8 @@ ink_freelists_dump_baselinerel(FILE * f)
     if (a != 0) {
       fprintf(f, " %18" PRIu64 " | %18" PRIu64 " | %7u | %10u | memory/%s\n",
               (uint64_t)(fll->fl->allocated - fll->fl->allocated_base) * 
(uint64_t)fll->fl->type_size,
-              (uint64_t)(fll->fl->used- fll->fl->used_base) * 
(uint64_t)fll->fl->type_size,
-              fll->fl->used - fll->fl->used_base, fll->fl->type_size, 
fll->fl->name ? fll->fl->name : "<unknown>");
+              (uint64_t)(fll->fl->used - fll->fl->used_base) * 
(uint64_t)fll->fl->type_size, fll->fl->used - fll->fl->used_base,
+              fll->fl->type_size, fll->fl->name ? fll->fl->name : "<unknown>");
     }
     fll = fll->next;
   }
@@ -428,7 +422,7 @@ ink_freelists_dump_baselinerel(FILE * f)
 }
 
 void
-ink_freelists_dump(FILE * f)
+ink_freelists_dump(FILE *f)
 {
 #if TS_USE_FREELIST
   ink_freelist_list *fll;
@@ -440,9 +434,9 @@ ink_freelists_dump(FILE * f)
 
   fll = freelists;
   while (fll) {
-    fprintf(f, " %18" PRIu64 " | %18" PRIu64 " | %10u | memory/%s\n",
-            (uint64_t)fll->fl->allocated * (uint64_t)fll->fl->type_size,
-            (uint64_t)fll->fl->used * (uint64_t)fll->fl->type_size, 
fll->fl->type_size, fll->fl->name ? fll->fl->name : "<unknown>");
+    fprintf(f, " %18" PRIu64 " | %18" PRIu64 " | %10u | memory/%s\n", 
(uint64_t)fll->fl->allocated * (uint64_t)fll->fl->type_size,
+            (uint64_t)fll->fl->used * (uint64_t)fll->fl->type_size, 
fll->fl->type_size,
+            fll->fl->name ? fll->fl->name : "<unknown>");
     fll = fll->next;
   }
 #else // ! TS_USE_FREELIST
@@ -452,7 +446,7 @@ ink_freelists_dump(FILE * f)
 
 
 void
-ink_atomiclist_init(InkAtomicList * l, const char *name, uint32_t 
offset_to_next)
+ink_atomiclist_init(InkAtomicList *l, const char *name, uint32_t 
offset_to_next)
 {
   l->name = name;
   l->offset = offset_to_next;
@@ -460,7 +454,7 @@ ink_atomiclist_init(InkAtomicList * l, const char *name, 
uint32_t offset_to_next
 }
 
 void *
-ink_atomiclist_pop(InkAtomicList * l)
+ink_atomiclist_pop(InkAtomicList *l)
 {
   head_p item;
   head_p next;
@@ -469,15 +463,13 @@ ink_atomiclist_pop(InkAtomicList * l)
     INK_QUEUE_LD(item, l->head);
     if (TO_PTR(FREELIST_POINTER(item)) == NULL)
       return NULL;
-    SET_FREELIST_POINTER_VERSION(next, 
*ADDRESS_OF_NEXT(TO_PTR(FREELIST_POINTER(item)), l->offset),
-                                 FREELIST_VERSION(item) + 1);
+    SET_FREELIST_POINTER_VERSION(next, 
*ADDRESS_OF_NEXT(TO_PTR(FREELIST_POINTER(item)), l->offset), 
FREELIST_VERSION(item) + 1);
 #if TS_HAS_128BIT_CAS
-       result = ink_atomic_cas((__int128_t*) & l->head.data, item.data, 
next.data);
+    result = ink_atomic_cas((__int128_t *)&l->head.data, item.data, next.data);
 #else
-       result = ink_atomic_cas((int64_t *) & l->head.data, item.data, 
next.data);
+    result = ink_atomic_cas((int64_t *)&l->head.data, item.data, next.data);
 #endif
-  }
-  while (result == 0);
+  } while (result == 0);
   {
     void *ret = TO_PTR(FREELIST_POINTER(item));
     *ADDRESS_OF_NEXT(ret, l->offset) = NULL;
@@ -486,7 +478,7 @@ ink_atomiclist_pop(InkAtomicList * l)
 }
 
 void *
-ink_atomiclist_popall(InkAtomicList * l)
+ink_atomiclist_popall(InkAtomicList *l)
 {
   head_p item;
   head_p next;
@@ -497,12 +489,11 @@ ink_atomiclist_popall(InkAtomicList * l)
       return NULL;
     SET_FREELIST_POINTER_VERSION(next, FROM_PTR(NULL), FREELIST_VERSION(item) 
+ 1);
 #if TS_HAS_128BIT_CAS
-       result = ink_atomic_cas((__int128_t*) & l->head.data, item.data, 
next.data);
+    result = ink_atomic_cas((__int128_t *)&l->head.data, item.data, next.data);
 #else
-       result = ink_atomic_cas((int64_t *) & l->head.data, item.data, 
next.data);
+    result = ink_atomic_cas((int64_t *)&l->head.data, item.data, next.data);
 #endif
-  }
-  while (result == 0);
+  } while (result == 0);
   {
     void *ret = TO_PTR(FREELIST_POINTER(item));
     void *e = ret;
@@ -517,9 +508,9 @@ ink_atomiclist_popall(InkAtomicList * l)
 }
 
 void *
-ink_atomiclist_push(InkAtomicList * l, void *item)
+ink_atomiclist_push(InkAtomicList *l, void *item)
 {
-  volatile void **adr_of_next = (volatile void **) ADDRESS_OF_NEXT(item, 
l->offset);
+  volatile void **adr_of_next = (volatile void **)ADDRESS_OF_NEXT(item, 
l->offset);
   head_p head;
   head_p item_pair;
   int result = 0;
@@ -532,18 +523,17 @@ ink_atomiclist_push(InkAtomicList * l, void *item)
     SET_FREELIST_POINTER_VERSION(item_pair, FROM_PTR(item), 
FREELIST_VERSION(head));
     INK_MEMORY_BARRIER;
 #if TS_HAS_128BIT_CAS
-       result = ink_atomic_cas((__int128_t*) & l->head, head.data, 
item_pair.data);
+    result = ink_atomic_cas((__int128_t *)&l->head, head.data, item_pair.data);
 #else
-       result = ink_atomic_cas((int64_t *) & l->head, head.data, 
item_pair.data);
+    result = ink_atomic_cas((int64_t *)&l->head, head.data, item_pair.data);
 #endif
-  }
-  while (result == 0);
+  } while (result == 0);
 
   return TO_PTR(h);
 }
 
 void *
-ink_atomiclist_remove(InkAtomicList * l, void *item)
+ink_atomiclist_remove(InkAtomicList *l, void *item)
 {
   head_p head;
   void *prev = NULL;
@@ -559,9 +549,9 @@ ink_atomiclist_remove(InkAtomicList * l, void *item)
     head_p next;
     SET_FREELIST_POINTER_VERSION(next, item_next, FREELIST_VERSION(head) + 1);
 #if TS_HAS_128BIT_CAS
-       result = ink_atomic_cas((__int128_t*) & l->head.data, head.data, 
next.data);
+    result = ink_atomic_cas((__int128_t *)&l->head.data, head.data, next.data);
 #else
-       result = ink_atomic_cas((int64_t *) & l->head.data, head.data, 
next.data);
+    result = ink_atomic_cas((int64_t *)&l->head.data, head.data, next.data);
 #endif
 
     if (result) {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/ink_queue.h
----------------------------------------------------------------------
diff --git a/lib/ts/ink_queue.h b/lib/ts/ink_queue.h
index 37e0953..8570d47 100644
--- a/lib/ts/ink_queue.h
+++ b/lib/ts/ink_queue.h
@@ -58,53 +58,50 @@
 */
 
 #ifdef __cplusplus
-extern "C"
-{
-#endif                          /* __cplusplus */
+extern "C" {
+#endif /* __cplusplus */
 
-  extern int fastmemtotal;
+extern int fastmemtotal;
 
-  void ink_queue_load_64(void *dst, void *src);
+void ink_queue_load_64(void *dst, void *src);
 
 #ifdef __x86_64__
-#define INK_QUEUE_LD64(dst,src) *((uint64_t*)&(dst)) = *((uint64_t*)&(src))
+#define INK_QUEUE_LD64(dst, src) *((uint64_t *)&(dst)) = *((uint64_t *)&(src))
 #else
-#define INK_QUEUE_LD64(dst,src) (ink_queue_load_64((void *)&(dst), (void 
*)&(src)))
+#define INK_QUEUE_LD64(dst, src) (ink_queue_load_64((void *)&(dst), (void 
*)&(src)))
 #endif
 
 #if TS_HAS_128BIT_CAS
-#define INK_QUEUE_LD(dst, src) do { \
-  *(__int128_t*)&(dst) = __sync_val_compare_and_swap((__int128_t*)&(src), 0, 
0); \
-} while (0)
+#define INK_QUEUE_LD(dst, src)                                                 
        \
+  do {                                                                         
        \
+    *(__int128_t *) & (dst) = __sync_val_compare_and_swap((__int128_t 
*)&(src), 0, 0); \
+  } while (0)
 #else
-#define INK_QUEUE_LD(dst,src) INK_QUEUE_LD64(dst,src)
+#define INK_QUEUE_LD(dst, src) INK_QUEUE_LD64(dst, src)
 #endif
 
 /*
  * Generic Free List Manager
  */
-  // Warning: head_p is read and written in multiple threads without a
-  // lock, use INK_QUEUE_LD to read safely.
-  typedef union
-  {
+// Warning: head_p is read and written in multiple threads without a
+// lock, use INK_QUEUE_LD to read safely.
+typedef union {
 #if (defined(__i386__) || defined(__arm__) || defined(__mips__)) && 
(SIZEOF_VOIDP == 4)
-    struct
-    {
-      void *pointer;
-      int32_t version;
-    } s;
-    int64_t data;
+  struct {
+    void *pointer;
+    int32_t version;
+  } s;
+  int64_t data;
 #elif TS_HAS_128BIT_CAS
-    struct
-    {
-      void *pointer;
-      int64_t version;
-    } s;
-    __int128_t data;
+  struct {
+    void *pointer;
+    int64_t version;
+  } s;
+  __int128_t data;
 #else
-    int64_t data;
+  int64_t data;
 #endif
-  } head_p;
+} head_p;
 
 /*
  * Why is version required? One scenario is described below
@@ -119,103 +116,99 @@ extern "C"
 #define ZERO_HEAD_P(_x)
 
 #ifdef DEBUG
-#define FROM_PTR(_x) (void*)(((uintptr_t)_x)+1)
-#define TO_PTR(_x) (void*)(((uintptr_t)_x)-1)
+#define FROM_PTR(_x) (void *)(((uintptr_t)_x) + 1)
+#define TO_PTR(_x) (void *)(((uintptr_t)_x) - 1)
 #else
-#define FROM_PTR(_x) ((void*)(_x))
-#define TO_PTR(_x) ((void*)(_x))
+#define FROM_PTR(_x) ((void *)(_x))
+#define TO_PTR(_x) ((void *)(_x))
 #endif
 
 #if (defined(__i386__) || defined(__arm__) || defined(__mips__)) && 
(SIZEOF_VOIDP == 4)
 #define FREELIST_POINTER(_x) (_x).s.pointer
 #define FREELIST_VERSION(_x) (_x).s.version
-#define SET_FREELIST_POINTER_VERSION(_x,_p,_v) \
-(_x).s.pointer = _p; (_x).s.version = _v
+#define SET_FREELIST_POINTER_VERSION(_x, _p, _v) \
+  (_x).s.pointer = _p;                           \
+  (_x).s.version = _v
 #elif TS_HAS_128BIT_CAS
 #define FREELIST_POINTER(_x) (_x).s.pointer
 #define FREELIST_VERSION(_x) (_x).s.version
-#define SET_FREELIST_POINTER_VERSION(_x,_p,_v) \
-(_x).s.pointer = _p; (_x).s.version = _v
+#define SET_FREELIST_POINTER_VERSION(_x, _p, _v) \
+  (_x).s.pointer = _p;                           \
+  (_x).s.version = _v
 #elif defined(__x86_64__) || defined(__ia64__) || defined(__powerpc64__) || 
defined(__aarch64__)
-#define FREELIST_POINTER(_x) ((void*)(((((intptr_t)(_x).data)<<16)>>16) | \
- (((~((((intptr_t)(_x).data)<<16>>63)-1))>>48)<<48)))  // sign extend
-#define FREELIST_VERSION(_x) (((intptr_t)(_x).data)>>48)
-#define SET_FREELIST_POINTER_VERSION(_x,_p,_v) \
-  (_x).data = ((((intptr_t)(_p))&0x0000FFFFFFFFFFFFULL) | (((_v)&0xFFFFULL) << 
48))
+#define FREELIST_POINTER(_x) \
+  ((void *)(((((intptr_t)(_x).data) << 16) >> 16) | 
(((~((((intptr_t)(_x).data) << 16 >> 63) - 1)) >> 48) << 48))) // sign extend
+#define FREELIST_VERSION(_x) (((intptr_t)(_x).data) >> 48)
+#define SET_FREELIST_POINTER_VERSION(_x, _p, _v) (_x).data = 
((((intptr_t)(_p)) & 0x0000FFFFFFFFFFFFULL) | (((_v)&0xFFFFULL) << 48))
 #else
 #error "unsupported processor"
 #endif
 
 #if TS_USE_RECLAIMABLE_FREELIST
-  extern float cfg_reclaim_factor;
-  extern int64_t cfg_max_overage;
-  extern int64_t cfg_enable_reclaim;
-  extern int64_t cfg_debug_filter;
+extern float cfg_reclaim_factor;
+extern int64_t cfg_max_overage;
+extern int64_t cfg_enable_reclaim;
+extern int64_t cfg_debug_filter;
 #else
-  struct _InkFreeList
-  {
-    volatile head_p head;
-    const char *name;
-    uint32_t type_size, chunk_size, used, allocated, alignment;
-    uint32_t allocated_base, used_base;
-    int advice;
-  };
-
-  inkcoreapi extern volatile int64_t fastalloc_mem_in_use;
-  inkcoreapi extern volatile int64_t fastalloc_mem_total;
-  inkcoreapi extern volatile int64_t freelist_allocated_mem;
+struct _InkFreeList {
+  volatile head_p head;
+  const char *name;
+  uint32_t type_size, chunk_size, used, allocated, alignment;
+  uint32_t allocated_base, used_base;
+  int advice;
+};
+
+inkcoreapi extern volatile int64_t fastalloc_mem_in_use;
+inkcoreapi extern volatile int64_t fastalloc_mem_total;
+inkcoreapi extern volatile int64_t freelist_allocated_mem;
 #endif
 
-  typedef struct _InkFreeList InkFreeList, *PInkFreeList;
-  typedef struct _ink_freelist_list
-  {
-    InkFreeList *fl;
-    struct _ink_freelist_list *next;
-  } ink_freelist_list;
-  extern ink_freelist_list *freelists;
-
-  /*
-   * alignment must be a power of 2
-   */
-  InkFreeList *ink_freelist_create(const char *name, uint32_t type_size,
-                                   uint32_t chunk_size, uint32_t alignment);
-
-  inkcoreapi void ink_freelist_init(InkFreeList **fl, const char *name,
-                                    uint32_t type_size, uint32_t chunk_size,
-                                    uint32_t alignment);
-  inkcoreapi void ink_freelist_madvise_init(InkFreeList **fl, const char 
*name, uint32_t type_size, uint32_t chunk_size, uint32_t alignment, int advice);
-  inkcoreapi void *ink_freelist_new(InkFreeList * f);
-  inkcoreapi void ink_freelist_free(InkFreeList * f, void *item);
-  inkcoreapi void ink_freelist_free_bulk(InkFreeList * f, void *head, void 
*tail, size_t num_item);
-  void ink_freelists_dump(FILE * f);
-  void ink_freelists_dump_baselinerel(FILE * f);
-  void ink_freelists_snap_baseline();
-
-  typedef struct
-  {
-    volatile head_p head;
-    const char *name;
-    uint32_t offset;
-  } InkAtomicList;
+typedef struct _InkFreeList InkFreeList, *PInkFreeList;
+typedef struct _ink_freelist_list {
+  InkFreeList *fl;
+  struct _ink_freelist_list *next;
+} ink_freelist_list;
+extern ink_freelist_list *freelists;
+
+/*
+ * alignment must be a power of 2
+ */
+InkFreeList *ink_freelist_create(const char *name, uint32_t type_size, 
uint32_t chunk_size, uint32_t alignment);
+
+inkcoreapi void ink_freelist_init(InkFreeList **fl, const char *name, uint32_t 
type_size, uint32_t chunk_size, uint32_t alignment);
+inkcoreapi void ink_freelist_madvise_init(InkFreeList **fl, const char *name, 
uint32_t type_size, uint32_t chunk_size,
+                                          uint32_t alignment, int advice);
+inkcoreapi void *ink_freelist_new(InkFreeList *f);
+inkcoreapi void ink_freelist_free(InkFreeList *f, void *item);
+inkcoreapi void ink_freelist_free_bulk(InkFreeList *f, void *head, void *tail, 
size_t num_item);
+void ink_freelists_dump(FILE *f);
+void ink_freelists_dump_baselinerel(FILE *f);
+void ink_freelists_snap_baseline();
+
+typedef struct {
+  volatile head_p head;
+  const char *name;
+  uint32_t offset;
+} InkAtomicList;
 
 #if !defined(INK_QUEUE_NT)
 #define INK_ATOMICLIST_EMPTY(_x) (!(TO_PTR(FREELIST_POINTER((_x.head)))))
 #else
-  /* ink_queue_nt.c doesn't do the FROM/TO pointer swizzling */
-#define INK_ATOMICLIST_EMPTY(_x) (!(      (FREELIST_POINTER((_x.head)))))
+/* ink_queue_nt.c doesn't do the FROM/TO pointer swizzling */
+#define INK_ATOMICLIST_EMPTY(_x) (!((FREELIST_POINTER((_x.head)))))
 #endif
 
-  inkcoreapi void ink_atomiclist_init(InkAtomicList * l, const char *name, 
uint32_t offset_to_next);
-  inkcoreapi void *ink_atomiclist_push(InkAtomicList * l, void *item);
-  void *ink_atomiclist_pop(InkAtomicList * l);
-  inkcoreapi void *ink_atomiclist_popall(InkAtomicList * l);
+inkcoreapi void ink_atomiclist_init(InkAtomicList *l, const char *name, 
uint32_t offset_to_next);
+inkcoreapi void *ink_atomiclist_push(InkAtomicList *l, void *item);
+void *ink_atomiclist_pop(InkAtomicList *l);
+inkcoreapi void *ink_atomiclist_popall(InkAtomicList *l);
 /*
  * WARNING WARNING WARNING WARNING WARNING WARNING WARNING
  * only if only one thread is doing pops it is possible to have a "remove"
  * which only that thread can use as well.
  * WARNING WARNING WARNING WARNING WARNING WARNING WARNING
  */
-  void *ink_atomiclist_remove(InkAtomicList * l, void *item);
+void *ink_atomiclist_remove(InkAtomicList *l, void *item);
 
 #ifdef __cplusplus
 }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/ink_queue_ext.cc
----------------------------------------------------------------------
diff --git a/lib/ts/ink_queue_ext.cc b/lib/ts/ink_queue_ext.cc
index ac99667..9687a74 100644
--- a/lib/ts/ink_queue_ext.cc
+++ b/lib/ts/ink_queue_ext.cc
@@ -45,11 +45,11 @@
 
 #if TS_USE_RECLAIMABLE_FREELIST
 
-#define CEIL(x,y)   (((x) + (y) - 1L) / (y))
-#define ROUND(x,l)  (((x) + ((l) - 1L)) & ~((l) - 1L))
+#define CEIL(x, y) (((x) + (y)-1L) / (y))
+#define ROUND(x, l) (((x) + ((l)-1L)) & ~((l)-1L))
 #define ITEM_MAGIC 0xFF
 
-#define MAX_NUM_FREELIST  1024
+#define MAX_NUM_FREELIST 1024
 
 /*
  * Configurable Variables
@@ -74,34 +74,21 @@ static __thread InkThreadCache 
*ThreadCaches[MAX_NUM_FREELIST];
 /*
  * For debug
  */
-#define show_info(tag, f, pCache) \
-  __show_info(stdout, __FILE__, __LINE__, tag, f, pCache)
-#define error_info(tag, f, pCache) \
-  __show_info(stderr, __FILE__, __LINE__, tag, f, pCache)
+#define show_info(tag, f, pCache) __show_info(stdout, __FILE__, __LINE__, tag, 
f, pCache)
+#define error_info(tag, f, pCache) __show_info(stderr, __FILE__, __LINE__, 
tag, f, pCache)
 
 static inline void
-__show_info(FILE *fp, const char *file, int line,
-            const char *tag, InkFreeList *f, InkThreadCache *pCache)
+__show_info(FILE *fp, const char *file, int line, const char *tag, InkFreeList 
*f, InkThreadCache *pCache)
 {
-
   fprintf(fp, "[%lx:%02u][%s:%05d][%s] %6.2fM t:%-8uf:%-4u m:%-4u avg:%-6.1f"
-          " M:%-4u csbase:%-4u csize:%-4u tsize:%-6u cbsize:%u\n",
-         (long)ink_thread_self(), f->thread_cache_idx, file, line, tag,
-         ((double)total_mem_in_byte/1024/1024),
-         pCache->nr_total,
-         pCache->nr_free,
-         pCache->nr_min,
-         pCache->nr_average,
-         pCache->nr_malloc,
-         f->chunk_size_base,
-         f->chunk_size,
-         f->type_size,
-         f->chunk_byte_size);
+              " M:%-4u csbase:%-4u csize:%-4u tsize:%-6u cbsize:%u\n",
+          (long)ink_thread_self(), f->thread_cache_idx, file, line, tag, 
((double)total_mem_in_byte / 1024 / 1024),
+          pCache->nr_total, pCache->nr_free, pCache->nr_min, 
pCache->nr_average, pCache->nr_malloc, f->chunk_size_base,
+          f->chunk_size, f->type_size, f->chunk_byte_size);
 }
 
 static inline void
-memory_alignment_init(InkFreeList *f, uint32_t type_size, uint32_t chunk_size,
-                      uint32_t alignment)
+memory_alignment_init(InkFreeList *f, uint32_t type_size, uint32_t chunk_size, 
uint32_t alignment)
 {
   uint32_t chunk_byte_size, user_alignment, user_type_size;
 
@@ -128,14 +115,11 @@ memory_alignment_init(InkFreeList *f, uint32_t type_size, 
uint32_t chunk_size,
   alignment = ats_pagesize();
   chunk_byte_size = ROUND(type_size + sizeof(InkChunkInfo), ats_pagesize());
   if (chunk_byte_size <= MAX_CHUNK_BYTE_SIZE) {
-
-    chunk_byte_size = ROUND(type_size * f->chunk_size_base
-                            + sizeof(InkChunkInfo), ats_pagesize());
+    chunk_byte_size = ROUND(type_size * f->chunk_size_base + 
sizeof(InkChunkInfo), ats_pagesize());
 
     if (chunk_byte_size > MAX_CHUNK_BYTE_SIZE) {
       chunk_size = (MAX_CHUNK_BYTE_SIZE - sizeof(InkChunkInfo)) / type_size;
-      chunk_byte_size = ROUND(type_size * chunk_size + sizeof(InkChunkInfo),
-                              ats_pagesize());
+      chunk_byte_size = ROUND(type_size * chunk_size + sizeof(InkChunkInfo), 
ats_pagesize());
     } else
       chunk_size = (chunk_byte_size - sizeof(InkChunkInfo)) / type_size;
 
@@ -169,8 +153,9 @@ memory_alignment_init(InkFreeList *f, uint32_t type_size, 
uint32_t chunk_size,
  *  1)the _size_ must be a multiple of page_size;
  *  2)the _alignment_ must be a power of page_size;
  */
-static void*
-mmap_align(size_t size, size_t alignment) {
+static void *
+mmap_align(size_t size, size_t alignment)
+{
   uintptr_t ptr;
   size_t adjust, extra = 0;
 
@@ -180,17 +165,13 @@ mmap_align(size_t size, size_t alignment) {
   if (alignment > ats_pagesize()) {
     extra = alignment - ats_pagesize();
   }
-  void* result = mmap(NULL, size + extra,
-                      PROT_READ|PROT_WRITE,
-                      MAP_PRIVATE|MAP_ANON,
-                      -1, 0);
+  void *result = mmap(NULL, size + extra, PROT_READ | PROT_WRITE, MAP_PRIVATE 
| MAP_ANON, -1, 0);
   if (result == MAP_FAILED) {
     ink_stack_trace_dump();
     const char *err_str = "Out of memory, or the process's maximum number of "
                           "mappings would have been exceeded(if so, you can "
                           "enlarge 'vm.max_map_count' by sysctl in linux).";
-    ink_fatal("Failed to mmap %zu bytes, %s", size,
-              (errno == ENOMEM) ? err_str : strerror(errno));
+    ink_fatal("Failed to mmap %zu bytes, %s", size, (errno == ENOMEM) ? 
err_str : strerror(errno));
   }
 
   /* adjust the return memory so it is aligned */
@@ -202,21 +183,20 @@ mmap_align(size_t size, size_t alignment) {
 
   /* return the unused memory to the system */
   if (adjust > 0) {
-    munmap((void*)ptr, adjust);
+    munmap((void *)ptr, adjust);
   }
   if (adjust < extra) {
-    munmap((void*)(ptr + adjust + size), extra - adjust);
+    munmap((void *)(ptr + adjust + size), extra - adjust);
   }
 
   ptr += adjust;
-  ink_assert((ptr & (alignment -1)) == 0);
-  return (void*)ptr;
+  ink_assert((ptr & (alignment - 1)) == 0);
+  return (void *)ptr;
 }
 
 #ifdef DEBUG
 static inline uint32_t
-get_chunk_item_magic_idx(InkFreeList *f, void *item, InkChunkInfo **ppChunk,
-                          bool do_check = false)
+get_chunk_item_magic_idx(InkFreeList *f, void *item, InkChunkInfo **ppChunk, 
bool do_check = false)
 {
   uint32_t idx;
   uintptr_t chunk_addr;
@@ -231,11 +211,10 @@ get_chunk_item_magic_idx(InkFreeList *f, void *item, 
InkChunkInfo **ppChunk,
 
   idx = ((uintptr_t)item - chunk_addr) / f->type_size;
 
-  if (do_check && (idx >= f->chunk_size
-                   || ((uintptr_t)item - chunk_addr) % f->type_size)) {
+  if (do_check && (idx >= f->chunk_size || ((uintptr_t)item - chunk_addr) % 
f->type_size)) {
     ink_stack_trace_dump();
-    ink_fatal("Invalid address:%p, chunk_addr:%p, type_size:%d, chunk_size:%u, 
idx:%u",
-              item, (void *)chunk_addr, f->type_size, f->chunk_size, idx);
+    ink_fatal("Invalid address:%p, chunk_addr:%p, type_size:%d, chunk_size:%u, 
idx:%u", item, (void *)chunk_addr, f->type_size,
+              f->chunk_size, idx);
   }
 
   return idx;
@@ -306,11 +285,11 @@ ink_chunk_create(InkFreeList *f, InkThreadCache *pCache)
   pChunk->link = Link<InkChunkInfo>();
 
 #ifdef DEBUG
-  /*
-   * The content will be initialized to zero when
-   * calls mmap() with MAP_ANONYMOUS flag on linux
-   * platform.
-   */
+/*
+ * The content will be initialized to zero when
+ * calls mmap() with MAP_ANONYMOUS flag on linux
+ * platform.
+ */
 #if !defined(linux)
   memset(pChunk->item_magic, 0, chunk_size * sizeof(unsigned char));
 #endif
@@ -388,13 +367,12 @@ malloc_whole_chunk(InkFreeList *f, InkThreadCache 
*pCache, InkChunkInfo *pChunk)
 }
 
 static inline void *
-malloc_from_chunk(InkFreeList * /* f ATS_UNUSED */,
-                  InkThreadCache *pCache, InkChunkInfo *pChunk)
+malloc_from_chunk(InkFreeList * /* f ATS_UNUSED */, InkThreadCache *pCache, 
InkChunkInfo *pChunk)
 {
   void *item;
 
   if ((item = pChunk->inner_free_list)) {
-    pChunk->inner_free_list  = *(void **)item;
+    pChunk->inner_free_list = *(void **)item;
     pChunk->allocated++;
     pCache->nr_total++;
   }
@@ -479,8 +457,7 @@ refresh_average_info(InkThreadCache *pCache)
   if (pCache->status == 1 || nr_free < pCache->nr_min)
     pCache->nr_min = nr_free;
 
-  pCache->nr_average = (nr_average * (1 - cfg_reclaim_factor)) +
-                       (nr_free * cfg_reclaim_factor);
+  pCache->nr_average = (nr_average * (1 - cfg_reclaim_factor)) + (nr_free * 
cfg_reclaim_factor);
 }
 
 static inline bool
@@ -489,8 +466,7 @@ need_to_reclaim(InkFreeList *f, InkThreadCache *pCache)
   if (!cfg_enable_reclaim)
     return false;
 
-  if(pCache->nr_free >= pCache->nr_average &&
-     pCache->nr_total > f->chunk_size_base) {
+  if (pCache->nr_free >= pCache->nr_average && pCache->nr_total > 
f->chunk_size_base) {
     if (pCache->nr_overage++ >= cfg_max_overage) {
       pCache->nr_overage = 0;
       return true;
@@ -503,9 +479,7 @@ need_to_reclaim(InkFreeList *f, InkThreadCache *pCache)
 }
 
 void
-reclaimable_freelist_init(InkFreeList **fl, const char *name,
-                          uint32_t type_size, uint32_t chunk_size,
-                          uint32_t alignment)
+reclaimable_freelist_init(InkFreeList **fl, const char *name, uint32_t 
type_size, uint32_t chunk_size, uint32_t alignment)
 {
   InkFreeList *f;
   ink_freelist_list *fll = freelists;
@@ -564,7 +538,7 @@ reclaimable_freelist_new(InkFreeList *f)
 
   /* no thread cache, create it */
   if (unlikely((pCache = ThreadCaches[f->thread_cache_idx]) == NULL)) {
-    pCache = (InkThreadCache *) ats_calloc(1, sizeof(InkThreadCache));
+    pCache = (InkThreadCache *)ats_calloc(1, sizeof(InkThreadCache));
 
     pCache->f = f;
     pCache->free_chunk_list = DLL<InkChunkInfo>();

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/ink_queue_ext.h
----------------------------------------------------------------------
diff --git a/lib/ts/ink_queue_ext.h b/lib/ts/ink_queue_ext.h
index 22ee6c4..4ff8402 100644
--- a/lib/ts/ink_queue_ext.h
+++ b/lib/ts/ink_queue_ext.h
@@ -34,107 +34,101 @@
 #include "ink_queue.h"
 
 #ifdef __cplusplus
-extern "C"
-{
-#endif                          /* __cplusplus */
+extern "C" {
+#endif /* __cplusplus */
 #if TS_USE_RECLAIMABLE_FREELIST
-  struct _InkThreadCache;
-  struct _InkFreeList;
+struct _InkThreadCache;
+struct _InkFreeList;
 
-  typedef struct _InkChunkInfo
-  {
-    pthread_t tid;
+typedef struct _InkChunkInfo {
+  pthread_t tid;
 
-    uint32_t type_size;
-    uint32_t chunk_size;
-    uint32_t allocated;
-    uint32_t length;
+  uint32_t type_size;
+  uint32_t chunk_size;
+  uint32_t allocated;
+  uint32_t length;
 
-    /*
-     * inner free list will only be
-     * accessed by creator-thread
-     */
-    void *inner_free_list;
-    void *head;
+  /*
+   * inner free list will only be
+   * accessed by creator-thread
+   */
+  void *inner_free_list;
+  void *head;
 
-    struct _InkThreadCache *pThreadCache;
+  struct _InkThreadCache *pThreadCache;
 
-    LINK(_InkChunkInfo, link);
+  LINK(_InkChunkInfo, link);
 
 #ifdef DEBUG
-    /*
-     * magic code for each item,
-     * it's used to check double-free issue.
-     */
-    unsigned char item_magic[0];
+  /*
+   * magic code for each item,
+   * it's used to check double-free issue.
+   */
+  unsigned char item_magic[0];
 #endif
-  } InkChunkInfo;
-
-  typedef struct _InkThreadCache
-  {
-    struct _InkFreeList *f;
-
-    /* outer free list will be accessed by:
-     * - creator-thread, asa producer-thread
-     * - consumer-thread
-     * - neighbor-thread
-     */
-    InkAtomicList outer_free_list;
-
-    /* using for memory reclaim algorithm */
-    float nr_average;
-    uint32_t nr_total;
-    uint32_t nr_free;
-    uint32_t nr_min;
-    uint32_t nr_overage;
-    uint32_t nr_malloc;
-
-    /* represent the status(state) of allocator: Malloc-ing(0) or Free-ing(1),
-     * I use it as an simple state machine - calculating the minimum of free
-     * memory only when the status change from Malloc-ing to Free-ing.
-     */
-    uint32_t status;
-
-    uint32_t nr_free_chunks;
-    DLL<InkChunkInfo> free_chunk_list;
-
-    _InkThreadCache *prev, *next;
-  } InkThreadCache;
-
-  typedef struct _InkFreeList
-  {
-    uint32_t thread_cache_idx;
-
-    uint32_t refcnt;
-    const char *name;
-
-    uint32_t type_size;
-    uint32_t alignment;
-
-    /* number of elements in one chunk */
-    uint32_t chunk_size;
-    /* total byte size of one chuck */
-    uint32_t chunk_byte_size;
-    /* chunk_addr = (uintptr_t)ptr & chunk_addr_mask */
-    uintptr_t chunk_addr_mask;
-
-    uint32_t used;
-    uint32_t allocated;
-    uint32_t allocated_base;
-    uint32_t used_base;
-    uint32_t chunk_size_base;
-
-    uint32_t nr_thread_cache;
-    InkThreadCache *pThreadCache;
-    ink_mutex lock;
-  } InkFreeList, *PInkFreeList;
-
-  /* reclaimable freelist API */
-  void reclaimable_freelist_init(InkFreeList **fl, const char *name,
-                                 uint32_t type_size, uint32_t chunk_size,
-                                 uint32_t alignment);
-  void *reclaimable_freelist_new(InkFreeList *f);
-  void reclaimable_freelist_free(InkFreeList *f, void *item);
+} InkChunkInfo;
+
+typedef struct _InkThreadCache {
+  struct _InkFreeList *f;
+
+  /* outer free list will be accessed by:
+   * - creator-thread, asa producer-thread
+   * - consumer-thread
+   * - neighbor-thread
+   */
+  InkAtomicList outer_free_list;
+
+  /* using for memory reclaim algorithm */
+  float nr_average;
+  uint32_t nr_total;
+  uint32_t nr_free;
+  uint32_t nr_min;
+  uint32_t nr_overage;
+  uint32_t nr_malloc;
+
+  /* represent the status(state) of allocator: Malloc-ing(0) or Free-ing(1),
+   * I use it as an simple state machine - calculating the minimum of free
+   * memory only when the status change from Malloc-ing to Free-ing.
+   */
+  uint32_t status;
+
+  uint32_t nr_free_chunks;
+  DLL<InkChunkInfo> free_chunk_list;
+
+  _InkThreadCache *prev, *next;
+} InkThreadCache;
+
+typedef struct _InkFreeList {
+  uint32_t thread_cache_idx;
+
+  uint32_t refcnt;
+  const char *name;
+
+  uint32_t type_size;
+  uint32_t alignment;
+
+  /* number of elements in one chunk */
+  uint32_t chunk_size;
+  /* total byte size of one chuck */
+  uint32_t chunk_byte_size;
+  /* chunk_addr = (uintptr_t)ptr & chunk_addr_mask */
+  uintptr_t chunk_addr_mask;
+
+  uint32_t used;
+  uint32_t allocated;
+  uint32_t allocated_base;
+  uint32_t used_base;
+  uint32_t chunk_size_base;
+
+  uint32_t nr_thread_cache;
+  InkThreadCache *pThreadCache;
+  ink_mutex lock;
+} InkFreeList, *PInkFreeList;
+
+/* reclaimable freelist API */
+void reclaimable_freelist_init(InkFreeList **fl, const char *name, uint32_t 
type_size, uint32_t chunk_size, uint32_t alignment);
+void *reclaimable_freelist_new(InkFreeList *f);
+void reclaimable_freelist_free(InkFreeList *f, void *item);
 #endif /* END OF TS_USE_RECLAIMABLE_FREELIST */
 #ifdef __cplusplus
 }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/ink_queue_utils.cc
----------------------------------------------------------------------
diff --git a/lib/ts/ink_queue_utils.cc b/lib/ts/ink_queue_utils.cc
index f93898b..25b5b6e 100644
--- a/lib/ts/ink_queue_utils.cc
+++ b/lib/ts/ink_queue_utils.cc
@@ -69,12 +69,12 @@ void
 ink_queue_load_64(void *dst, void *src)
 {
 #if (defined(__i386__) || defined(__arm__) || defined(__mips__)) && 
(SIZEOF_VOIDP == 4)
-  volatile int32_t src_version = (*(head_p *) src).s.version;
-  void *src_pointer = (*(head_p *) src).s.pointer;
+  volatile int32_t src_version = (*(head_p *)src).s.version;
+  void *src_pointer = (*(head_p *)src).s.pointer;
 
-  (*(head_p *) dst).s.version = src_version;
-  (*(head_p *) dst).s.pointer = src_pointer;
+  (*(head_p *)dst).s.version = src_version;
+  (*(head_p *)dst).s.pointer = src_pointer;
 #else
-  *(void**)dst = *(void**)src;
+  *(void **)dst = *(void **)src;
 #endif
 }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/ink_rand.cc
----------------------------------------------------------------------
diff --git a/lib/ts/ink_rand.cc b/lib/ts/ink_rand.cc
index e9989e0..b4c780f 100644
--- a/lib/ts/ink_rand.cc
+++ b/lib/ts/ink_rand.cc
@@ -61,35 +61,40 @@
 #define MM 156
 #define MATRIX_A 0xB5026F5AA96619E9ULL
 #define UM 0xFFFFFFFF80000000ULL /* Most significant 33 bits */
-#define LM 0x7FFFFFFFULL /* Least significant 31 bits */
+#define LM 0x7FFFFFFFULL         /* Least significant 31 bits */
 
-static uint64_t mag01[2]={0ULL, MATRIX_A};
+static uint64_t mag01[2] = {0ULL, MATRIX_A};
 
-InkRand::InkRand(uint64_t d) {
+InkRand::InkRand(uint64_t d)
+{
   seed(d);
 }
 
-void InkRand::seed(uint64_t seed) {
+void
+InkRand::seed(uint64_t seed)
+{
   mt[0] = seed;
-  for (mti=1; mti<NN; mti++)
-    mt[mti] =  (6364136223846793005ULL * (mt[mti-1] ^ (mt[mti-1] >> 62)) + 
mti);
+  for (mti = 1; mti < NN; mti++)
+    mt[mti] = (6364136223846793005ULL * (mt[mti - 1] ^ (mt[mti - 1] >> 62)) + 
mti);
 }
 
-uint64_t InkRand::random() {
+uint64_t
+InkRand::random()
+{
   int i;
   uint64_t x;
 
   if (mti >= NN) { /* generate NN words at one time */
-    for (i=0;i<NN-MM;i++) {
-      x = (mt[i]&UM)|(mt[i+1]&LM);
-      mt[i] = mt[i+MM] ^ (x>>1) ^ mag01[(int)(x&1ULL)];
+    for (i = 0; i < NN - MM; i++) {
+      x = (mt[i] & UM) | (mt[i + 1] & LM);
+      mt[i] = mt[i + MM] ^ (x >> 1) ^ mag01[(int)(x & 1ULL)];
     }
-    for (;i<NN-1;i++) {
-      x = (mt[i]&UM)|(mt[i+1]&LM);
-      mt[i] = mt[i+(MM-NN)] ^ (x>>1) ^ mag01[(int)(x&1ULL)];
+    for (; i < NN - 1; i++) {
+      x = (mt[i] & UM) | (mt[i + 1] & LM);
+      mt[i] = mt[i + (MM - NN)] ^ (x >> 1) ^ mag01[(int)(x & 1ULL)];
     }
-    x = (mt[NN-1]&UM)|(mt[0]&LM);
-    mt[NN-1] = mt[MM-1] ^ (x>>1) ^ mag01[(int)(x&1ULL)];
+    x = (mt[NN - 1] & UM) | (mt[0] & LM);
+    mt[NN - 1] = mt[MM - 1] ^ (x >> 1) ^ mag01[(int)(x & 1ULL)];
 
     mti = 0;
   }
@@ -104,6 +109,8 @@ uint64_t InkRand::random() {
   return x;
 }
 
-double InkRand::drandom() {
-  return (random() >> 11) * (1.0/9007199254740991.0);
+double
+InkRand::drandom()
+{
+  return (random() >> 11) * (1.0 / 9007199254740991.0);
 }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/ink_rand.h
----------------------------------------------------------------------
diff --git a/lib/ts/ink_rand.h b/lib/ts/ink_rand.h
index f9b78bd..93c4d51 100644
--- a/lib/ts/ink_rand.h
+++ b/lib/ts/ink_rand.h
@@ -80,9 +80,10 @@ private:
   int mti;
 };
 
-inline int ink_rand_r(uint32_t * p) {
-  return (((*p) = (*p) * 1103515245 + 12345) % ((uint32_t) 0x7fffffff + 1));
+inline int
+ink_rand_r(uint32_t *p)
+{
+  return (((*p) = (*p) * 1103515245 + 12345) % ((uint32_t)0x7fffffff + 1));
 }
 
 #endif /* __INK_RAND_H__ */
-

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/ink_res_init.cc
----------------------------------------------------------------------
diff --git a/lib/ts/ink_res_init.cc b/lib/ts/ink_res_init.cc
index c9a0ed8..8dbe091 100644
--- a/lib/ts/ink_res_init.cc
+++ b/lib/ts/ink_res_init.cc
@@ -90,25 +90,17 @@
 #include "ink_inet.h"
 #include "Tokenizer.h"
 
-#if !defined(isascii)           /* XXX - could be a function */
-# define isascii(c) (!(c & 0200))
+#if !defined(isascii) /* XXX - could be a function */
+#define isascii(c) (!(c & 0200))
 #endif
 
-HostResPreferenceOrder const HOST_RES_DEFAULT_PREFERENCE_ORDER = {
-  HOST_RES_PREFER_IPV4,
-  HOST_RES_PREFER_IPV6,
-  HOST_RES_PREFER_NONE
-};
+HostResPreferenceOrder const HOST_RES_DEFAULT_PREFERENCE_ORDER = 
{HOST_RES_PREFER_IPV4, HOST_RES_PREFER_IPV6, HOST_RES_PREFER_NONE};
 
 HostResPreferenceOrder host_res_default_preference_order;
 
-char const* const HOST_RES_PREFERENCE_STRING[N_HOST_RES_PREFERENCE] = {
-    "only", "client", "ipv4", "ipv6"
-};
+char const *const HOST_RES_PREFERENCE_STRING[N_HOST_RES_PREFERENCE] = {"only", 
"client", "ipv4", "ipv6"};
 
-char const* const HOST_RES_STYLE_STRING[] = {
-  "invalid", "IPv4", "IPv4 only", "IPv6", "IPv6 only"
-};
+char const *const HOST_RES_STYLE_STRING[] = {"invalid", "IPv4", "IPv4 only", 
"IPv6", "IPv6 only"};
 
 /*%
  * This routine is for closing the socket if a virtual circuit is used and
@@ -118,16 +110,18 @@ char const* const HOST_RES_STYLE_STRING[] = {
  * This routine is not expected to be user visible.
  */
 static void
-ink_res_nclose(ink_res_state statp) {
+ink_res_nclose(ink_res_state statp)
+{
   if (statp->_vcsock >= 0) {
-    (void) close(statp->_vcsock);
+    (void)close(statp->_vcsock);
     statp->_vcsock = -1;
     statp->_flags &= ~(INK_RES_F_VC | INK_RES_F_CONN);
   }
 }
 
 static void
-ink_res_setservers(ink_res_state statp, IpEndpoint const* set, int cnt) {
+ink_res_setservers(ink_res_state statp, IpEndpoint const *set, int cnt)
+{
   /* close open servers */
   ink_res_nclose(statp);
 
@@ -139,8 +133,8 @@ ink_res_setservers(ink_res_state statp, IpEndpoint const* 
set, int cnt) {
      the destination and sourcea are the same.
   */
   int nserv = 0;
-  for ( IpEndpoint const* limit = set + cnt ; nserv < INK_MAXNS && set < limit 
; ++set ) {
-    IpEndpoint* dst = &statp->nsaddr_list[nserv];
+  for (IpEndpoint const *limit = set + cnt; nserv < INK_MAXNS && set < limit; 
++set) {
+    IpEndpoint *dst = &statp->nsaddr_list[nserv];
 
     if (dst == set) {
       if (ats_is_ip(&set->sa))
@@ -153,9 +147,10 @@ ink_res_setservers(ink_res_state statp, IpEndpoint const* 
set, int cnt) {
 }
 
 int
-ink_res_getservers(ink_res_state statp, sockaddr *set, int cnt) {
+ink_res_getservers(ink_res_state statp, sockaddr *set, int cnt)
+{
   int zret = 0; // return count.
-  IpEndpoint const* src = statp->nsaddr_list;
+  IpEndpoint const *src = statp->nsaddr_list;
 
   for (int i = 0; i < statp->nscount && i < cnt; ++i, ++src) {
     if (ats_ip_copy(set, &src->sa)) {
@@ -201,7 +196,7 @@ ink_res_setoptions(ink_res_state statp, const char 
*options, const char *source
       if (statp->options & INK_RES_DEBUG)
         printf(";;\ttimeout=%d\n", statp->retrans);
 #endif
-#ifdef SOLARIS2
+#ifdef SOLARIS2
     } else if (!strncmp(cp, "retrans:", sizeof("retrans:") - 1)) {
       /*
        * For backward compatibility, 'retrans' is
@@ -209,15 +204,15 @@ ink_res_setoptions(ink_res_state statp, const char 
*options, const char *source
        * without an imposed maximum.
        */
       statp->retrans = atoi(cp + sizeof("retrans:") - 1);
-    } else if (!strncmp(cp, "retry:", sizeof("retry:") - 1)){
+    } else if (!strncmp(cp, "retry:", sizeof("retry:") - 1)) {
       /*
        * For backward compatibility, 'retry' is
        * supported as an alias for 'attempts', though
        * without an imposed maximum.
        */
       statp->retry = atoi(cp + sizeof("retry:") - 1);
-#endif /* SOLARIS2 */
-    } else if (!strncmp(cp, "attempts:", sizeof("attempts:") - 1)){
+#endif /* SOLARIS2 */
+    } else if (!strncmp(cp, "attempts:", sizeof("attempts:") - 1)) {
       i = atoi(cp + sizeof("attempts:") - 1);
       if (i <= INK_RES_MAXRETRY)
         statp->retry = i;
@@ -252,8 +247,7 @@ ink_res_setoptions(ink_res_state statp, const char 
*options, const char *source
 #endif
     else if (!strncmp(cp, "dname", sizeof("dname") - 1)) {
       statp->options |= INK_RES_USE_DNAME;
-    }
-    else {
+    } else {
       /* XXX - print a warning here? */
     }
     /* skip to next run of spaces */
@@ -263,7 +257,8 @@ ink_res_setoptions(ink_res_state statp, const char 
*options, const char *source
 }
 
 static unsigned
-ink_res_randomid(void) {
+ink_res_randomid(void)
+{
   struct timeval now;
 
   gettimeofday(&now, NULL);
@@ -294,14 +289,14 @@ ink_res_randomid(void) {
  * @internal This function has to be reachable by res_data.c but not 
publically.
  */
 int
-ink_res_init(
-  ink_res_state statp, ///< State object to update.
-  IpEndpoint const* pHostList, ///< Additional servers.
-  size_t pHostListSize, ///< # of entries in @a pHostList.
-  const char *pDefDomain, ///< Default domain (may be NULL).
-  const char *pSearchList, ///< Unknown
-  const char *pResolvConf ///< Path to configuration file.
-) {
+ink_res_init(ink_res_state statp,         ///< State object to update.
+             IpEndpoint const *pHostList, ///< Additional servers.
+             size_t pHostListSize,        ///< # of entries in @a pHostList.
+             const char *pDefDomain,      ///< Default domain (may be NULL).
+             const char *pSearchList,     ///< Unknown
+             const char *pResolvConf      ///< Path to configuration file.
+             )
+{
   FILE *fp;
   char *cp, **pp;
   int n;
@@ -328,7 +323,7 @@ ink_res_init(
   statp->qhook = NULL;
   statp->rhook = NULL;
 
-#ifdef SOLARIS2
+#ifdef SOLARIS2
   /*
    * The old libresolv derived the defaultdomain from NIS/NIS+.
    * We want to keep this behaviour
@@ -337,8 +332,7 @@ ink_res_init(
     char buf[sizeof(statp->defdname)], *cp;
     int ret;
 
-    if ((ret = sysinfo(SI_SRPC_DOMAIN, buf, sizeof(buf))) > 0 &&
-        (unsigned int)ret <= sizeof(buf)) {
+    if ((ret = sysinfo(SI_SRPC_DOMAIN, buf, sizeof(buf))) > 0 && (unsigned 
int)ret <= sizeof(buf)) {
       if (buf[0] == '+')
         buf[0] = '.';
       cp = strchr(buf, '.');
@@ -346,9 +340,9 @@ ink_res_init(
       ink_strlcpy(statp->defdname, cp, sizeof(statp->defdname));
     }
   }
-#endif /* SOLARIS2 */
+#endif /* SOLARIS2 */
 
-       /* Allow user to override the local domain definition */
+  /* Allow user to override the local domain definition */
   if ((cp = getenv("LOCALDOMAIN")) != NULL) {
     (void)ink_strlcpy(statp->defdname, cp, sizeof(statp->defdname));
     haveenv++;
@@ -364,7 +358,7 @@ ink_res_init(
     pp = statp->dnsrch;
     *pp++ = cp;
     for (n = 0; *cp && pp < statp->dnsrch + INK_MAXDNSRCH; cp++) {
-      if (*cp == '\n') /*%< silly backwards compat */
+      if (*cp == '\n') /*%< silly backwards compat */
         break;
       else if (*cp == ' ' || *cp == '\t') {
         *cp = 0;
@@ -428,20 +422,15 @@ ink_res_init(
      we must be provided with atleast a named!
      ------------------------------------------- */
   if (pHostList) {
-    if (pHostListSize > INK_MAXNS) pHostListSize = INK_MAXNS;
-    for (
-        ; nserv < pHostListSize
-          && ats_is_ip(&pHostList[nserv].sa)
-        ; ++nserv
-    ) {
+    if (pHostListSize > INK_MAXNS)
+      pHostListSize = INK_MAXNS;
+    for (; nserv < pHostListSize && ats_is_ip(&pHostList[nserv].sa); ++nserv) {
       ats_ip_copy(&statp->nsaddr_list[nserv].sa, &pHostList[nserv].sa);
     }
   }
 
-#define        MATCH(line, name)                       \
-  (!strncmp(line, name, sizeof(name) - 1) &&    \
-   (line[sizeof(name) - 1] == ' ' ||            \
-    line[sizeof(name) - 1] == '\t'))
+#define MATCH(line, name) \
+  (!strncmp(line, name, sizeof(name) - 1) && (line[sizeof(name) - 1] == ' ' || 
line[sizeof(name) - 1] == '\t'))
 
   if ((fp = fopen(pResolvConf, "r")) != NULL) {
     /* read the config file */
@@ -451,7 +440,7 @@ ink_res_init(
         continue;
       /* read default domain name */
       if (MATCH(buf, "domain")) {
-        if (haveenv)   /*%< skip if have from environ */
+        if (haveenv) /*%< skip if have from environ */
           continue;
         cp = buf + sizeof("domain") - 1;
         while (*cp == ' ' || *cp == '\t')
@@ -466,7 +455,7 @@ ink_res_init(
       }
       /* set search list */
       if (MATCH(buf, "search")) {
-        if (haveenv)   /*%< skip if have from environ */
+        if (haveenv) /*%< skip if have from environ */
           continue;
         cp = buf + sizeof("search") - 1;
         while (*cp == ' ' || *cp == '\t')
@@ -512,14 +501,11 @@ ink_res_init(
         if ((*cp != '\0') && (*cp != '\n')) {
           memset(&hints, 0, sizeof(hints));
           hints.ai_family = PF_UNSPEC;
-          hints.ai_socktype = SOCK_DGRAM;      /*dummy*/
+          hints.ai_socktype = SOCK_DGRAM; /*dummy*/
           hints.ai_flags = AI_NUMERICHOST;
           sprintf(sbuf, "%d", NAMESERVER_PORT);
           if (getaddrinfo(cp, sbuf, &hints, &ai) == 0) {
-            if (ats_ip_copy(
-                &statp->nsaddr_list[nserv].sa,
-                ai->ai_addr
-            ))
+            if (ats_ip_copy(&statp->nsaddr_list[nserv].sa, ai->ai_addr))
               ++nserv;
             freeaddrinfo(ai);
           }
@@ -531,7 +517,7 @@ ink_res_init(
         continue;
       }
     }
-    (void) fclose(fp);
+    (void)fclose(fp);
   }
 
   if (nserv > 0)
@@ -554,7 +540,7 @@ ink_res_init(
     while (pp < statp->dnsrch + INK_MAXDFLSRCH) {
       if (dots < INK_LOCALDOMAINPARTS)
         break;
-      cp = strchr(cp, '.') + 1;    /*%< we know there is one */
+      cp = strchr(cp, '.') + 1; /*%< we know there is one */
       *pp++ = cp;
       dots--;
     }
@@ -579,21 +565,22 @@ ink_res_init(
 }
 
 void
-parse_host_res_preference(char const* value, HostResPreferenceOrder order) {
+parse_host_res_preference(char const *value, HostResPreferenceOrder order)
+{
   Tokenizer tokens(";/|");
   // preference from the config string.
-  int np = 0; // index in to @a m_host_res_preference
-  bool found[N_HOST_RES_PREFERENCE];  // redundancy check array
-  int n; // # of tokens
-  int i; // index
+  int np = 0;                        // index in to @a m_host_res_preference
+  bool found[N_HOST_RES_PREFERENCE]; // redundancy check array
+  int n;                             // # of tokens
+  int i;                             // index
 
   n = tokens.Initialize(value);
 
-  for ( i = 0 ; i < N_HOST_RES_PREFERENCE ; ++i )
+  for (i = 0; i < N_HOST_RES_PREFERENCE; ++i)
     found[i] = false;
 
-  for ( i = 0 ; i < n && np < N_HOST_RES_PREFERENCE_ORDER ; ++i ) {
-    char const* elt = tokens[i];
+  for (i = 0; i < n && np < N_HOST_RES_PREFERENCE_ORDER; ++i) {
+    char const *elt = tokens[i];
     // special case none/only because that terminates the sequence.
     if (0 == strcasecmp(elt, 
HOST_RES_PREFERENCE_STRING[HOST_RES_PREFER_NONE])) {
       found[HOST_RES_PREFER_NONE] = true;
@@ -602,7 +589,7 @@ parse_host_res_preference(char const* value, 
HostResPreferenceOrder order) {
     } else {
       // scan the other types
       HostResPreference ep = HOST_RES_PREFER_NONE;
-      for ( int ip = HOST_RES_PREFER_NONE + 1 ; ip < N_HOST_RES_PREFERENCE ; 
++ip ) {
+      for (int ip = HOST_RES_PREFER_NONE + 1; ip < N_HOST_RES_PREFERENCE; 
++ip) {
         if (0 == strcasecmp(elt, HOST_RES_PREFERENCE_STRING[ip])) {
           ep = static_cast<HostResPreference>(ip);
           break;
@@ -627,17 +614,17 @@ parse_host_res_preference(char const* value, 
HostResPreferenceOrder order) {
 }
 
 int
-ts_host_res_order_to_string(HostResPreferenceOrder const& order, char* out, 
int size)
+ts_host_res_order_to_string(HostResPreferenceOrder const &order, char *out, 
int size)
 {
   int zret = 0;
   bool first = true;
-  for ( int i = 0 ; i < N_HOST_RES_PREFERENCE_ORDER ; ++i ) {
+  for (int i = 0; i < N_HOST_RES_PREFERENCE_ORDER; ++i) {
     /* Note we use a semi-colon here because this must be compatible
      * with the -httpport command line option which uses comma to
      * separate port descriptors so we cannot use that to separate
      * resolution key words.
      */
-    zret += snprintf(out+zret, size-zret, "%s%s", !first ? ";" : "", 
HOST_RES_PREFERENCE_STRING[order[i]]);
+    zret += snprintf(out + zret, size - zret, "%s%s", !first ? ";" : "", 
HOST_RES_PREFERENCE_STRING[order[i]]);
     if (HOST_RES_PREFER_NONE == order[i])
       break;
     first = false;

Reply via email to