Livoa LogoLivoa
| Module name / UI label     | Function name(s) in code                      | Description                                                                                      |
|---------------------------|----------------------------------------------|--------------------------------------------------------------------------------------------------|
| Create cache / Initialize  | lru_create(int capacity)                      | Allocate and initialize cache structure, hash table, and dummy head/tail nodes for the doubly linked list. |
| Free cache / Cleanup       | lru_free(LRUCache *c)                         | Free all nodes, free hash table and cache structure; ensure no memory leaks.                      |
| Visit / Put (cache page)   | lru_put(LRUCache *c, const char *url, const char *content) | Insert a URL and its content into cache; if key exists update content and move node to MRU; if capacity exceeded pop LRU and evict (remove from DLL and hash). |
| Access / Get (load page)   | lru_get(LRUCache *c, const char *url)        | Look up URL in hash table; on hit move node to MRU (front of DLL) and return content; on miss return NULL. |
| Eviction (LRU remove)      | dll_pop_tail, hash_remove (used inside lru_put) | Remove least-recently-used node from DLL and remove its entry from hash table; free node memory.  |
| Doubly linked-list helpers | dll_add_to_head, dll_remove, dll_move_to_head, dll_pop_tail | Manipulate DLL for recency ordering (insert at head, remove node, promote node, pop tail).        |
| Hash-table helpers         | hash_string, hash_find, hash_insert, hash_remove | Compute bucket index, lookup node by URL, insert node into hash chain, and remove node from chain. |
| Node management            | free_node, xstrdup                            | Create/duplicate string memory safely and free node contents.                                   |
| Display cache state        | lru_print(LRUCache *c)                        | Print current cache entries from most- to least-recently-used for debugging / report screenshots. |
| View page content          | print_page(const char *url, const char *content) | Pretty-print page content when a cached URL is loaded.                                          |
| Demo scenario              | demo_scenario(LRUCache *c)                    | A scripted sequence of puts and gets to demonstrate cache behavior (used for screenshots / testing). |
| Console UI & input helpers | main(), read_line, trim                       | Menu loop (visit/access/show/demo/exit) and safe input reading/trimming for user interaction.     |
Module name / UI labelFunction name(s) in codeDescription
Create cache / Initializelru_create(int capacity)Allocate and initialize cache structure, hash table, and dummy head/tail nodes for the doubly linked list.
Free cache / Cleanuplru_free(LRUCache *c)Free all nodes, free hash table and cache structure; ensure no memory leaks.
Visit / Put (cache page)lru_put(LRUCache *c, const char *url, const char *content)Insert a URL and its content into cache; if key exists update content and move node to MRU; if capacity exceeded pop LRU and evict (remove from DLL and hash).
Access / Get (load page)lru_get(LRUCache *c, const char *url)Look up URL in hash table; on hit move node to MRU (front of DLL) and return content; on miss return NULL.
Eviction (LRU remove)dll_pop_tail, hash_remove (used inside lru_put)Remove least-recently-used node from DLL and remove its entry from hash table; free node memory.
Doubly linked-list helpersdll_add_to_head, dll_remove, dll_move_to_head, dll_pop_tailManipulate DLL for recency ordering (insert at head, remove node, promote node, pop tail).
Hash-table helpershash_string, hash_find, hash_insert, hash_removeCompute bucket index, lookup node by URL, insert node into hash chain, and remove node from chain.
Node managementfree_node, xstrdupCreate/duplicate string memory safely and free node contents.
Display cache statelru_print(LRUCache *c)Print current cache entries from most- to least-recently-used for debugging / report screenshots.
View page contentprint_page(const char *url, const char *content)Pretty-print page content when a cached URL is loaded.
Demo scenariodemo_scenario(LRUCache *c)A scripted sequence of puts and gets to demonstrate cache behavior (used for screenshots / testing).
Console UI & input helpersmain(), read_line, trimMenu loop (visit/access/show/demo/exit) and safe input reading/trimming for user interaction.

abc

by sakshi

0
0 uses