John Breaux
90ab3166a2
list: * create block, list * create link(), unlink(), init(), print() main: * create main * test list actions
30 lines
608 B
C++
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);
|
|
}
|
|
}
|