Modestus Moon OS
R4
CS 450 project
|
#include "linked_list.h"
Go to the source code of this file.
Functions | |
void | initLinkedList (linkedList_t *list) |
initilize list and the optional array that backs the list More... | |
node_t * | makeNewNode (linkedList_t *list, void *data) |
get new node, allocate a new node or find an unused node from the list's pool More... | |
void | setInsertComparisonFunction (linkedList_t *list, int(*newCompFunc)(void *, void *)) |
takes in a function pointer and sets the library shared comparison pointer More... | |
void | setFreeFunction (linkedList_t *list, int(*newFreeFunc)(node_t *)) |
sets the function whose job it is to free the node's memory More... | |
void | setSearchComparisonFunction (linkedList_t *list, int(*newSearchFunc)(void *, void *)) |
sets the function whose job it is to compare the input data with the data in the list. the first void parameter will always be the data contained in the list, the second will be the data passed to the search function. More... | |
node_t * | insertAfterNode (node_t *preceedingNode, node_t *newNode) |
insert a node into the parent list of the preceedingNode after preceedingNode More... | |
node_t * | insertBeforeNode (node_t *nodeToFollow, node_t *newNode) |
insert a node into the parent list of the nodeToFollow before nodeToFollow More... | |
node_t * | removeNode (node_t *nodeToRemove) |
will remove the node from the list. the list hierarchy will change to reflect the missing node. More... | |
node_t * | moveNodeToNewList (node_t *nodeToMove, linkedList_t *newList) |
If a node needs to move lists and lists are array backed, instead of just moving preceeding and suceeding pointers of the node, the node actaully needs to move backing arrays so one list's nodes are not the only ones being consumed. The equivalent process will be to execute the parent list's removeNode funcion, execute the makeNewNode function on the newList, copy all structure members to the new node, and return the new node. The list of nodeToMove freeNodeFunc will be called with nodeToMov as the argument. If the lists are not array backed, the function simply removes the node from its containing list and calls insertNode on the new list. More... | |
node_t * | searchList (linkedList_t *listToSearch, void *data) |
goes through the list using the list's comparison function to find the node which matches the data. if the search function is undefined for this list, the function returns null immedietly. More... | |
node_t * | insertNode (linkedList_t *list, node_t *newNode) |
Will insert the node into the list. This function will attempt to call the list's insert comparison function if defined. The function will insert the new node into the list after this function returns > 0. If the insert comparison function is not defined for this list, the inserting function will placed the new node at the end of the list before the tail. More... | |
void | setPrintFunction (linkedList_t *list, void(*newPrintFunc)(void *)) |
sets the function whose job it is to print the list to the screen. More... | |
void | printList (linkedList_t *list) |
test function to show list functionality. uses const char* as test data More... | |
int | compFunction (void *nodeData1, void *nodeData2) |
int | searchcompFunction (void *nodeData1, void *nodeData2) |
void | testPrintFunc (void *nodeData) |
void | listTest () |
test the linked_list class with const char* data and output to screen the results of the test More... | |
int compFunction | ( | void * | nodeData1, |
void * | nodeData2 | ||
) |
Definition at line 231 of file linked_list.c.
Referenced by listTest().
void initLinkedList | ( | linkedList_t * | list | ) |
initilize list and the optional array that backs the list
list | pointer to list |
Definition at line 3 of file linked_list.c.
References MAX_NUM_OF_LL_NODES.
Referenced by initHeap(), initPCBQueues(), and listTest().
insert a node into the parent list of the preceedingNode after preceedingNode
preceedingNode | node to insert the new node afterwards |
newNode | the new node to insert. if the list is array backed, the newNode will be copied to the list's node pool if it currently does not reside there |
Definition at line 78 of file linked_list.c.
References moveNodeToNewList().
insert a node into the parent list of the nodeToFollow before nodeToFollow
nodeToFollow | node to insert the newNode before |
newNode | the new node to insert. if the list is array backed, the newNode will be copied to the list's node pool if it currently does not reside there |
Definition at line 99 of file linked_list.c.
References moveNodeToNewList().
Referenced by insertNode().
node_t* insertNode | ( | linkedList_t * | list, |
node_t * | newNode | ||
) |
Will insert the node into the list. This function will attempt to call the list's insert comparison function if defined. The function will insert the new node into the list after this function returns > 0. If the insert comparison function is not defined for this list, the inserting function will placed the new node at the end of the list before the tail.
list | list to place the node |
newNode | the new node to insert. if the list is array backed, the newNode will be copied to the list's node pool if it currently does not reside there |
Definition at line 173 of file linked_list.c.
References insertBeforeNode(), and moveNodeToNewList().
Referenced by insertMCBIntoList(), insertPCB(), listTest(), and moveNodeToNewList().
void listTest | ( | ) |
test the linked_list class with const char* data and output to screen the results of the test
Definition at line 250 of file linked_list.c.
References compFunction(), initLinkedList(), insertNode(), makeNewNode(), printf, printList(), searchcompFunction(), searchList(), setInsertComparisonFunction(), setPrintFunction(), setSearchComparisonFunction(), and testPrintFunc().
node_t* makeNewNode | ( | linkedList_t * | list, |
void * | data | ||
) |
get new node, allocate a new node or find an unused node from the list's pool
list | to find an unused node from. This argument is ignored if the list is dynamically allocated |
data | pointer to the data the new node should contain, the pointer must be valid obviously |
Definition at line 37 of file linked_list.c.
References MAX_NUM_OF_LL_NODES, and sys_alloc_mem().
Referenced by allocatePCB(), listTest(), and moveNodeToNewList().
node_t* moveNodeToNewList | ( | node_t * | nodeToMove, |
linkedList_t * | newList | ||
) |
If a node needs to move lists and lists are array backed, instead of just moving preceeding and suceeding pointers of the node, the node actaully needs to move backing arrays so one list's nodes are not the only ones being consumed. The equivalent process will be to execute the parent list's removeNode funcion, execute the makeNewNode function on the newList, copy all structure members to the new node, and return the new node. The list of nodeToMove freeNodeFunc will be called with nodeToMov as the argument. If the lists are not array backed, the function simply removes the node from its containing list and calls insertNode on the new list.
nodeToMove | the node to move, this pointer is no longer guarenteed to be valid. Stop using this pointer, |
newList | the list to move the node to, this will be the node's new parent list |
Definition at line 132 of file linked_list.c.
References insertNode(), makeNewNode(), and removeNode().
Referenced by insertAfterNode(), insertBeforeNode(), and insertNode().
void printList | ( | linkedList_t * | list | ) |
test function to show list functionality. uses const char* as test data
list | list to print the nodes of |
Definition at line 212 of file linked_list.c.
References printf.
Referenced by heapTest(), listTest(), mcbFunc(), pcbTest(), printAlloc(), printFree(), showAllProcesses(), showBlockedProcesses(), and showReadyProcesses().
will remove the node from the list. the list hierarchy will change to reflect the missing node.
nodeToRemove | pointer to the node to remove |
Definition at line 120 of file linked_list.c.
Referenced by allocateMemFromHeap(), freeHeapMem(), moveNodeToNewList(), reclaimFreeMem(), and removePCB().
int searchcompFunction | ( | void * | nodeData1, |
void * | nodeData2 | ||
) |
Definition at line 238 of file linked_list.c.
References strcmp().
Referenced by listTest().
node_t* searchList | ( | linkedList_t * | listToSearch, |
void * | data | ||
) |
goes through the list using the list's comparison function to find the node which matches the data. if the search function is undefined for this list, the function returns null immedietly.
listToSearch | the list to search |
data | valid pointer to data that can be dereferenced. this pointer will be the second argument to the list's search comparison function |
Definition at line 154 of file linked_list.c.
Referenced by findPCB(), freeHeapMem(), and listTest().
void setFreeFunction | ( | linkedList_t * | list, |
int(*)(node_t *) | newFreeFunc | ||
) |
sets the function whose job it is to free the node's memory
list | the list to set the function pointer for |
newFreeFunc | the job of this function should be to free the memory with the node once it the list no longer needs it. This can be literally through free() or by other means. |
Definition at line 68 of file linked_list.c.
void setInsertComparisonFunction | ( | linkedList_t * | list, |
int(*)(void *, void *) | newCompFunc | ||
) |
takes in a function pointer and sets the library shared comparison pointer
list | the list to set the function pointer for |
newCompFunc | pointer to function whose job is to define the comparison of the data stored in the node this function should return 0 if the comparison succeeds. The function should return < 0 if the data to compare comes after the data in the node. The function should return > 0 if the data to compare comes before the data in the node. The first void argument is guarenteed to be the data from the list to compare against. The second void argument is the data in the node passed to the insertNode function |
Definition at line 63 of file linked_list.c.
Referenced by initHeap(), and listTest().
void setSearchComparisonFunction | ( | linkedList_t * | list, |
int(*)(void *, void *) | newSearchFunc | ||
) |
sets the function whose job it is to compare the input data with the data in the list. the first void parameter will always be the data contained in the list, the second will be the data passed to the search function.
list | to set the search function for |
newSeachFunc | pointer to function whose job is to define the comparison of the data stored in the node this function should return 0 if the comparison succeeds. The function should return < 0 if the data to compare comes after the data in the node. The function should return > 0 if the data to compare comes before the data in the node. The first void argument is guarenteed to be the data from the list to compare against. The second void argument is the data passed to the searchList function |
Definition at line 73 of file linked_list.c.
Referenced by initHeap(), initPCBQueues(), and listTest().
void testPrintFunc | ( | void * | nodeData | ) |
Definition at line 245 of file linked_list.c.
References printf.
Referenced by listTest().