Hash *copy_frame(Hash *frame){ Hash *copy = create_empty_frame(); void add_key_value(void *key){ void *value = hash_value(frame, key); frame_add(copy, key, value); }
Hash *frame_create(List *args, List *values){ Hash *frame = create_empty_frame(); while (args != NULL && values != NULL){ frame_add(frame, args->car, values->car); args = args->cdr; values = values->cdr; } die_unless(args == NULL && values == NULL, "Arg names and values have different lengths"); return frame; }
/** * Algorithm_Data* create_algo_data_store(int num_frames) * * Creates an empty Algorithm_Data to init an Algorithm * * @return {Algorithm_Data*} empty Algorithm_Data struct for an Algorithm */ Algorithm_Data *create_algo_data_store() { Algorithm_Data *data = malloc(sizeof(Algorithm_Data)); data->hits = 0; data->misses = 0; data->last_victim = NULL; /* Initialize Lists */ LIST_INIT(&(data->page_table)); LIST_INIT(&(data->victim_list)); /* Insert at the page_table. */ Frame *framep = create_empty_frame(0); LIST_INSERT_HEAD(&(data->page_table), framep, frames); /* Build the rest of the list. */ size_t i = 0; for (i = 1; i < num_frames; ++i) { LIST_INSERT_AFTER(framep, create_empty_frame(i), frames); framep = framep->frames.le_next; } return data; }