diff options
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; +} |