=====BACKGROUND===== In this project, we will be building on top of what we did in sln0. In sln0, we made pseudocode and submitted pictures of what happened in our pseudocode. For sln1, we are beginning to implement that into actual c code. The pseudocode and pictures should give us a good idea of what we are actually trying to accomplish in this project. Remember: Nodes only hold a value and a pointer. This pointer will point to the next node, unless it is the last node, in which case it points to NULL. If it is the only node, it qualifies as the last node. =====SPECIFICATIONS===== In simple words, after you've grabbed the project files, it is our task to edit the cp.c mk.c, and rm.c files inside the '//sln1/src/node/ //' directory and make them work. cp.c standing for copy, mk.c is our program that creates node, and rm.c is our program to remove nodes. We have many files for reference at our disposal. The most important files to execute, read, and analyze are contained within the '//sln1/unit/node/ //' directory. These source code files will be your guides, to get your files to work. As explained down below in the Unit Test section, another set of important files is contained within the '//sln1/bin/ //' directory. Run these files for testing. //You will find a "node.h" file in the provided include directory (sln1/inc/node.h) which provides a **struct node** that will serve as the structure of the Node that you will be manipulating // (may find information pertaining to the various node options) The mknode() program should allocate memory for a new node, verify that the allocation was successful, and then populate and return the address to the new node. The rmnode() program should only de-allocate the node passed into the program. =====Reminder===== Whenever you allocate a resource, check that the memory allocation, be that for a file or a pointer, is valid. In other words, check that your pointer/file is not NULL. \\ \\ \\ \\
Our task is to ask questions on Discord or in class and document our findings on this wiki page collaboratively, regarding the functionality of this project. For anybody interested in editing the wiki page, here is the dokuwiki user guide: https://www.dokuwiki.org/wiki:syntax#basic_text_formatting -Ash=====PROGRAM===== Program should be able to perform specifications displayed inside the files. For example, inside src/node/mk.c, rm.c, and cp.c should be able to make nodes, remove nodes, and copy nodes, respectively. Some files inside app/node/ have little to no needed code and only test your src/node/ files. If your files are made correctly and to project specifications it should work well and similar to some of your sln0 pseudocode. Most, if not all, of the specifications will be commented inside the files with what you need to do.\\ When making the three programs, first look at "node.h" as it will tell you how to go about programing them, for example when making a node you know that the node will have a node->right and a node->info. When copying the node you do not need to allocate space, rather use an existing function. When removing you should think about how malloc works and what the node would become. In each of these codes think about what it is you want to be returned.\\ **Directories containing vital project information:** * ''/inc/'' contains your header files used in most programs(contains options used such as "right" and "info") * ''/unit/node/'' contains your unit tests for mk.c, rm.c, and cp.c * ''/src/node/'' contains the mk.c, rm.c, and cp.c files * ''/app/node/'' supplemental information/tests to further your understanding of the "node code" =====OUTPUT SPECIFICATIONS===== There does not appear to be any direct output required for this project.
#if !defined(UNDEFINED)
#define UNDEFINED ((void*)1)
#endif
You might be wondering the need for this line; why not just use NULL? Conceptually, NULL and UNDEFINED mean the same thing: nothing. However, due to the nature of our unit tests, we need a way to differentiate between untouched (undefined) memory and memory that has been modified to be NULL. It is for this reason that rmnode() is to return NULL and not UNDEFINED.
=====NOTE=====
Before running the 'make' command, remove the "errors" file because running make appends new errors onto the end of the errors file. This means that when you read the errors file you will be reading old errors that may or may not exist since 'make' does not delete the old errors file in this project.
Also, use the 'make clean' command before running 'make' after adjusting your code, I found that I was rerunning old executables with non-functional code even after I made changes to it until I ran 'make clean'. If your code is failing to compile or if it is mismatched, try a make clean as well.