4600-project-1/main.cpp
John Breaux 90ab3166a2 Start the project
list:
* create block, list
* create link(), unlink(), init(), print()
main:
* create main
* test list actions
2022-04-03 11:39:40 -05:00

30 lines
608 B
C++

#include <cstdint>
#include <cstdio>
#include "list.hpp"
#define N 0x8
// Create all of memory
block memory[N] = {0};
// create the three lists
list freelist = {0}, list1 = {0}, list2 = {0};
int main (int argc, char* argv[]) {
// initialize the freelist
list_init(&freelist, memory, N);
// print the list
list_print(&freelist);
list_print(&list1);
// move a block
block* b;
while (b = list_unlink(&freelist)) {
list_link(&list1, b);
// print the list
std::printf("\n");
list_print(&freelist);
list_print(&list1);
}
}