tally: fix FreeBSD compile, memleak in tests.
authorRusty Russell <rusty@rustcorp.com.au>
Tue, 21 Jun 2011 01:13:31 +0000 (10:43 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Tue, 21 Jun 2011 01:13:31 +0000 (10:43 +0930)
Posix says ssize_t is in sys/types.h; on Linux stdlib.h is enough.

ccan/tally/tally.c
ccan/tally/tally.h
ccan/tally/test/run-mean.c
ccan/tally/test/run-median.c
ccan/tally/test/run-min-max.c
ccan/tally/test/run-mode.c
ccan/tally/test/run-renormalize.c

index 0d0190795557b60ccfe8d73138dfda2baf99477d..b1839befe3b4016287ded6203767be305e65b657 100644 (file)
@@ -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)
 
index e7157175075cb556d2ff7cd5c74d07b95ee3fd3d..650e2656cd888b7c624455550b573b93f035fb52 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef CCAN_TALLY_H
 #define CCAN_TALLY_H
-#include <stdlib.h>
+#include "config.h"
+#include <sys/types.h>
 
 struct tally;
 
index a4a67cf9c8e0885b1b6e49f130a289ef4cf2a3ba..b43dea6b2861cd062fb52ff83d1840aaa2304497 100644 (file)
@@ -25,5 +25,6 @@ int main(void)
                ok1(tally_mean(tally) == 0);
        }
 
+       free(tally);
        return exit_status();
 }
index f461c2ec8f9b71f1dc7b2dac1de1ff1d163b0f4c..b12fd8a021a191bddef52f9ec23738ea178bd5c8 100644 (file)
@@ -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();
 }
index ffb0f2eff497714a648bbcdafb30e0af10433d72..c92f6d382a490356224826ed96f121d4bfd7ef2c 100644 (file)
@@ -16,5 +16,6 @@ int main(void)
                ok1(tally_max(tally) == i);
                ok1(tally_min(tally) == -i);
        }
+       free(tally);
        return exit_status();
 }
index 7216738bfbef95c9fb12682f33635a094611b750..cd2f23044367b894d9a30a8f0ed76c3f9c19a46a 100644 (file)
@@ -41,5 +41,6 @@ int main(void)
                ok1(mode - (ssize_t)err <= 0 && mode + (ssize_t)err >= 0);
        }
 
+       free(tally);
        return exit_status();
 }
index 7c141528d236b82335edf4923fd7117f252059f3..8fe9dbce329c1576a9762c2e14a0ca03123cc4ff 100644 (file)
@@ -21,5 +21,6 @@ int main(void)
        ok1(tally->counts[0] == 2);
        ok1(tally->counts[1] == 0);
 
+       free(tally);
        return exit_status();
 }