diff options
author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2021-05-31 06:11:22 -0700 |
---|---|---|
committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2021-05-31 06:11:22 -0700 |
commit | 18bde7391efb9c6bd6ea7846891ab5d16276a809 (patch) | |
tree | 237cc152edbdf934ed32e4c8c54c5ce97535e57f /quotes.c | |
download | stonks-master.tar.gz stonks-master.tar.xz |
A bit messy and missing error handling in some places.
Diffstat (limited to 'quotes.c')
-rw-r--r-- | quotes.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/quotes.c b/quotes.c new file mode 100644 index 0000000..5e269e0 --- /dev/null +++ b/quotes.c @@ -0,0 +1,23 @@ +#include "quotes.h" + +#include <stdlib.h> +#include <string.h> + +void quote_free(struct quote *q) +{ + free(q->symbol); + free(q->currency); + free(q); +} + +struct quote *quote_find(struct quote **quotes, int n_quotes, + const char *symbol, const char *currency) +{ + for (int i = 0; i < n_quotes; ++i) { + if (strcmp(quotes[i]->symbol, symbol) == 0 && + strcmp(quotes[i]->currency, currency) == 0) + return quotes[i]; + } + + return NULL; +} |