From a31fde98e4f182c6dda1028adf1c68e2d7a8c647 Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Thu, 28 Apr 2016 01:39:57 -0400 Subject: [PATCH] Add find_line --- csim.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/csim.c b/csim.c index 2ecd605..08ff657 100644 --- a/csim.c +++ b/csim.c @@ -197,6 +197,18 @@ void print_set(linked_line* line) } } +/** + @returns the first line with a matching tag, the first invalid line, + or the first line without an older (i.e. the end of the set + */ +linked_line* find_line(linked_line* line, long tag) +{ + if(line->tag == tag || !line->validity || !line->older) + return line; + else + return find_line(line->older, tag); +} + void print_usage(void) { printf("Usage: ./csim [-hv] -s -E -b -t \n"