| #include <stdio.h> |
| #include <stdlib.h> |
| #include <assert.h> |
| #include "median.h" |
| |
| // A sinple main routine meant as an example, |
| // and also to unit test most of the intersting |
| // functions of the median module. |
| int main(int argc, char * argv[]) { |
| // Call suggest buffer size to determine the size of the buffer |
| // we need to build the data structure. |
| size_t n = 0; |
| assert(median_suggest_buffer_size(.001, 1000, &n) == MEDIAN_OK); |
| // Print the number out. |
| printf("%ld\n", n); |
| |
| // Allocate the buffer of the required size. And then |
| // initialize it (median_init_buffer). |
| void * b = malloc(n); |
| median_buffer_t buf; |
| assert(median_init_buffer(b, n, .001, 1000, &buf) == MEDIAN_OK); |
| |
| // All done, return 0 |
| return 0; |
| } |