commit cb06b448c534ac99ddd08f264e6f86162ddd6b72
Author: Mika Eloranta <mel@ohmu.fi>
Date:   Wed Apr 30 04:41:19 2014 +0000

    pgmemcache: correct free function for memcached_stat_get_value
    
    libmemcached 1.0.16 and greater switched to using malloc for
    values returned from memcached_stat_get_value.

diff --git a/pgmemcache.c b/pgmemcache.c
index f1ef04f..7e6795f 100644
--- a/pgmemcache.c
+++ b/pgmemcache.c
@@ -818,7 +818,7 @@ static memcached_return_t server_stat_function(memcached_st *ptr,
     {
       char *value = memcached_stat_get_value(ptr, &stat, *stat_ptr, &rc);
       appendStringInfo(context, "%s: %s\n", *stat_ptr, value);
-      pfree(value);
+      libmc_stat_free(value);
     }
 
   pfree(list);
diff --git a/pgmemcache.h b/pgmemcache.h
index ff8e9e8..686c140 100644
--- a/pgmemcache.h
+++ b/pgmemcache.h
@@ -36,6 +36,13 @@
 #undef PACKAGE_TARNAME
 #undef PACKAGE_VERSION
 
+/* libmemcached 1.0.16 changed the allocation function for values returned from memcached_stat_get_value */
+#if LIBMEMCACHED_VERSION_HEX >= 0x01000016
+  #define libmc_stat_free free
+#else
+  #define libmc_stat_free pfree
+#endif
+
 void _PG_init(void);
 void _PG_fini(void);
 
