39 lines
726 B
C++
39 lines
726 B
C++
#include <cstdint>
|
|
#include <cstdio>
|
|
#include "list.hpp"
|
|
|
|
#define N 0x8
|
|
|
|
int movement_test ();
|
|
|
|
int main(int argc, char *argv[]) {
|
|
movement_test();
|
|
}
|
|
|
|
int movement_test () {
|
|
|
|
// Create all of memory
|
|
block memory[N] = {0};
|
|
// create the three lists
|
|
list freelist = {0}, list1 = {0};
|
|
// initialize the freelist
|
|
list_init(&freelist, memory, N);
|
|
|
|
// print the lists
|
|
std::printf("Lists:\n");
|
|
list_print(&freelist);
|
|
list_print(&list1);
|
|
|
|
// move a block
|
|
block *b;
|
|
while (b = list_unlink(&freelist))
|
|
{
|
|
list_link(&list1, b);
|
|
}
|
|
// print the lists again (should be reversed order)
|
|
std::printf("Lists, again:\n");
|
|
list_print(&freelist);
|
|
list_print(&list1);
|
|
return 1;
|
|
}
|