Seperated chart from box; fixed kkr segfault.
This commit is contained in:
32
chart.c
Normal file
32
chart.c
Normal file
@@ -0,0 +1,32 @@
|
||||
|
||||
/*
|
||||
* Copyright (C) Artsiom D.
|
||||
* Copyright (C) shit-co.de
|
||||
*/
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "chart.h"
|
||||
#include "util.h"
|
||||
|
||||
|
||||
struct chart new_chart(unsigned int length)
|
||||
{
|
||||
unsigned int i;
|
||||
double price;
|
||||
struct chart chart;
|
||||
|
||||
chart.prices = emalloc(sizeof(double) * length);
|
||||
chart.length = length;
|
||||
|
||||
/* populate with random prices */
|
||||
|
||||
price = 10;
|
||||
|
||||
for (i = 0; i < length; i++) {
|
||||
chart.prices[i] = price;
|
||||
price += (double)rand() / RAND_MAX - 0.4;
|
||||
}
|
||||
|
||||
return chart;
|
||||
}
|
||||
Reference in New Issue
Block a user