Add find_line

This commit is contained in:
Adam Goldsmith 2016-04-28 01:39:57 -04:00
parent 88240dab06
commit a31fde98e4
1 changed files with 12 additions and 0 deletions

12
csim.c
View File

@ -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) void print_usage(void)
{ {
printf("Usage: ./csim [-hv] -s <number> -E <number> -b <number> -t <file>\n" printf("Usage: ./csim [-hv] -s <number> -E <number> -b <number> -t <file>\n"