We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
//somedefs.h
#include #include
using namespace std;
union FreeList { union FreeList* next; // 指向下一个区块 char data; // 储存本块内存的首地址 };
int main() { FreeList* free_list[56] = { nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr, nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr, nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr, nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr, nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr, nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr, nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr }; FreeList *head = (FreeList *)malloc(sizeof(FreeList)); FreeList one = (FreeList )malloc(sizeof(FreeList)); one->data = 'A'; head->next = one; free_list[0] = head; FreeList my_free_list; FreeList result;
//allocate my_free_list = free_list[0]; result = my_free_list; my_free_list = result->next;
//deallocate head->next = my_free_list; my_free_list = head; char k = free_list[0]->next->data; std::cout << k << std::endl; }
这是仿写的你的allocate和deallocate操作链表,free_list确实变了啊,不太理解,能跟我说一下吗,谢谢你
The text was updated successfully, but these errors were encountered:
//somedefs.h #include #include using namespace std; union FreeList { union FreeList* next; // 指向下一个区块 char data; // 储存本块内存的首地址 }; int main() { FreeList* free_list[56] = { nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr, nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr, nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr, nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr, nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr, nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr, nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr }; FreeList *head = (FreeList *)malloc(sizeof(FreeList)); FreeList one = (FreeList )malloc(sizeof(FreeList)); one->data = 'A'; head->next = one; free_list[0] = head; FreeList my_free_list; FreeList result; //allocate my_free_list = free_list[0]; result = my_free_list; my_free_list = result->next; //deallocate head->next = my_free_list; my_free_list = head; char k = free_list[0]->next->data; std::cout << k << std::endl; } 这是仿写的你的allocate和deallocate操作链表,free_list确实变了啊,不太理解,能跟我说一下吗,谢谢你
Sorry, something went wrong.
No branches or pull requests
//somedefs.h
#include
#include
using namespace std;
union FreeList
{
union FreeList* next; // 指向下一个区块
char data; // 储存本块内存的首地址
};
int main()
{
FreeList* free_list[56] = {
nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,
nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,
nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,
nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,
nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,
nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,
nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr
};
FreeList *head = (FreeList *)malloc(sizeof(FreeList));
FreeList one = (FreeList )malloc(sizeof(FreeList));
one->data = 'A';
head->next = one;
free_list[0] = head;
FreeList my_free_list;
FreeList result;
//allocate
my_free_list = free_list[0];
result = my_free_list;
my_free_list = result->next;
//deallocate
head->next = my_free_list;
my_free_list = head;
char k = free_list[0]->next->data;
std::cout << k << std::endl;
}
这是仿写的你的allocate和deallocate操作链表,free_list确实变了啊,不太理解,能跟我说一下吗,谢谢你
The text was updated successfully, but these errors were encountered: