X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=netem%2Fnormal.c;h=dbdebb1d08e312a6d3c3ad7af22eefb4894870c3;hb=refs%2Fheads%2Ffedora;hp=e6683db8946680910815b05ac8be96b80449e819;hpb=cb820e861caa85bb3942ab0c673e04b9408be0ad;p=iproute2.git diff --git a/netem/normal.c b/netem/normal.c index e6683db..dbdebb1 100644 --- a/netem/normal.c +++ b/netem/normal.c @@ -20,21 +20,16 @@ normal(double x, double mu, double sigma) return .5 + .5*erf((x-mu)/(sqrt(2.0)*sigma)); } + int main(int argc, char **argv) { - double x, *table; int i, n; - - table = calloc(sizeof(double), TABLESIZE+1); - if (!table) { - fprintf(stderr, "Not enough memory\n"); - return 1; - } - + double x; + double table[TABLESIZE+1]; for (x = -10.0; x < 10.05; x += .00005) { - i = (int)rint(TABLESIZE*normal(x, 0.0, 1.0)); + i = rint(TABLESIZE * normal(x, 0.0, 1.0)); table[i] = x; } @@ -51,6 +46,6 @@ main(int argc, char **argv) n = 0; } } - free(table); + return 0; }