Browse Source

tally: fix FreeBSD compile, memleak in tests.

Posix says ssize_t is in sys/types.h; on Linux stdlib.h is enough.
Rusty Russell 14 years ago
parent
commit
0284423676

+ 1 - 1
ccan/tally/tally.c

@@ -1,4 +1,3 @@
-#include "config.h"
 #include <ccan/tally/tally.h>
 #include <ccan/build_assert/build_assert.h>
 #include <ccan/likely/likely.h>
@@ -7,6 +6,7 @@
 #include <string.h>
 #include <stdio.h>
 #include <assert.h>
+#include <stdlib.h>
 
 #define SIZET_BITS (sizeof(size_t)*CHAR_BIT)
 

+ 2 - 1
ccan/tally/tally.h

@@ -1,6 +1,7 @@
 #ifndef CCAN_TALLY_H
 #define CCAN_TALLY_H
-#include <stdlib.h>
+#include "config.h"
+#include <sys/types.h>
 
 struct tally;
 

+ 1 - 0
ccan/tally/test/run-mean.c

@@ -25,5 +25,6 @@ int main(void)
 		ok1(tally_mean(tally) == 0);
 	}
 
+	free(tally);
 	return exit_status();
 }

+ 1 - 0
ccan/tally/test/run-median.c

@@ -40,6 +40,7 @@ int main(void)
 		ok1(median - (ssize_t)err <= i/2
 		    && median + (ssize_t)err >= i/2);
 	}
+	free(tally);
 
 	return exit_status();
 }

+ 1 - 0
ccan/tally/test/run-min-max.c

@@ -16,5 +16,6 @@ int main(void)
 		ok1(tally_max(tally) == i);
 		ok1(tally_min(tally) == -i);
 	}
+	free(tally);
 	return exit_status();
 }

+ 1 - 0
ccan/tally/test/run-mode.c

@@ -41,5 +41,6 @@ int main(void)
 		ok1(mode - (ssize_t)err <= 0 && mode + (ssize_t)err >= 0);
 	}
 
+	free(tally);
 	return exit_status();
 }

+ 1 - 0
ccan/tally/test/run-renormalize.c

@@ -21,5 +21,6 @@ int main(void)
 	ok1(tally->counts[0] == 2);
 	ok1(tally->counts[1] == 0);
 
+	free(tally);
 	return exit_status();
 }