walk_stats() doesn't free memory. I added in the free() calls which
seems to fix the leak, but please review as my XS skills are a few years
old now.
Subject: | libmemcached_walk_stats.diff |
--- libmemcached.xs.orig 2008-05-27 05:46:25.000000000 -0700
+++ libmemcached.xs 2008-12-06 15:36:50.000000000 -0800
@@ -867,6 +867,7 @@
for (i = 0; i < server_count; i++) {
SV *hostport_sv;
char **keys;
+ char **key_list;
char *val;
hostport_sv = sv_2mortal(newSVpvf("%s:%d",
@@ -874,7 +875,7 @@
memcached_server_port(ptr, servers[i])
));
- keys = memcached_stat_get_keys(ptr, &stat[i], &rc);
+ key_list = keys = memcached_stat_get_keys(ptr, &stat[i], &rc);
while (keys && *keys) {
int items;
dSP;
@@ -900,12 +901,17 @@
if (items) /* XXX may use returned items for signalling later */
croak("walk_stats callback returned non-empty list");
+ free(val);
+
+
FREETMPS;
LEAVE;
keys++;
}
+ free(key_list);
}
+ free(stat);
OUTPUT:
RETVAL