Fix number of sets/lines created

This commit is contained in:
Adam Goldsmith 2016-04-27 22:16:01 -04:00
parent b556be1622
commit c26d27db9d
1 changed files with 3 additions and 2 deletions

5
csim.c
View File

@ -131,7 +131,7 @@ linked_line** make_cache(long set_indices, long num_lines)
{
linked_line** cache = (linked_line**)calloc(set_indices, sizeof(linked_line*));
long ii;
for (ii = 0; ii < num_lines; ii++) {
for (ii = 0; ii < set_indices; ii++) {
cache[ii] = make_set(NULL, num_lines);
}
return cache;
@ -146,8 +146,9 @@ linked_line** make_cache(long set_indices, long num_lines)
linked_line* make_set(linked_line* newer, long num_lines) {
linked_line* current = (linked_line*)calloc(1, sizeof(linked_line));
current->newer = newer;
num_lines--;
if (num_lines) { // If not on the last line
current->older = make_set(current, num_lines-1);
current->older = make_set(current, num_lines);
}
else {
current->older = NULL;