?? form1.h
字號(hào):
//_myGraphics->DrawString("0x123456789", _BusyFont, _BusyBrush, _BusyItem[1].X, _BusyItem[1].Y + _BusyItem[1].Height);
}
///<summary>
///隨機(jī)分配內(nèi)存測(cè)試按鈕
///</summary>
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e)
{
Random^ randObj = gcnew Random();
int i = randObj->Next(32, (G_TestMemLen / 10));
//i = 1024;
do
{
if((Test_sp[Test_sp_num] = (char *)Fun_Malloc(i)) != NULL)
{
Test_Space[Test_sp_num] = i;
Test_sp_num += 1;
Test_Alloc_Mem += i;
break;
}
else
{
if((G_TestMemLen - Test_Alloc_Mem - Test_sp_num * 32 - 16) <= 32)
{
return;
}
i = randObj->Next(32, (G_TestMemLen - Test_Alloc_Mem - Test_sp_num * 32 - 16));
continue;
}
}
while(1);
this->textBox1->Text = Test_sp_num.ToString();
}
///<summary>
///繪制忙鏈表Checked
///</summary>
private: System::Void checkBox1_CheckedChanged(System::Object^ sender, System::EventArgs^ e)
{
if(this->checkBox1->Checked == false)
{
_myGraphics->Clear(this->pictureBox1->BackColor);
return;
}
int i;
!_BusyItem; //釋放
!_BusyItemPoint;
!_BusyItemInfo;
i = Fun_RetBusyList();
_BusyItemSum = i;
if(i == 0)
{
return;
}
_BusyItem = gcnew array<Rectangle>(i);
_BusyItemPoint = gcnew array<Point,2>(i, 4);
_BusyItemInfo = gcnew array<String^, 2>(i, 8);
Sub_ComputerRectAndPoint(_BusyItem, _BusyItemPoint, Org_X, Org_Y, i);
int Next, Prev, Addr, SpaceSize, Mem_LB, Mem_RB, SelfAddr, BusyFlag;
int j, ret;
for(j = 0; j < i; j++)
{
ret = Fun_RetBusyListItemInfo(j + 1, &Next, &Prev, &Addr, &SpaceSize, &Mem_LB, &Mem_RB, &SelfAddr, &BusyFlag);
if(ret == 1)
{
_BusyItemInfo[j, 0] = "Next:" + Next.ToString("X");
_BusyItemInfo[j, 1] = "Prev:" + Prev.ToString("X");
_BusyItemInfo[j, 2] = "Addr:" + Addr.ToString("X");
_BusyItemInfo[j, 3] = "Spac:" + SpaceSize.ToString();
_BusyItemInfo[j, 4] = "MeLb:" + Mem_LB.ToString("X");
_BusyItemInfo[j, 5] = "MeRb:" + Mem_RB.ToString("X");
_BusyItemInfo[j, 6] = "Self:" + SelfAddr.ToString("X");
_BusyItemInfo[j, 7] = "Busy:" + BusyFlag.ToString("X");
}
}
Sub_DrawList(_BusyItem, _BusyItemPoint, _BusyPen, _BusyBrush, _BusyItemInfo, _BusyFont, i);
}
///<summary>
///分析繁忙鏈表按鈕
///</summary>
private: System::Void button4_Click(System::Object^ sender, System::EventArgs^ e)
{
int i;
!_BusyItemInfo;
i = Fun_RetBusyList();
_BusyItemSum = i;
if(i != Test_sp_num)
{
}
else
{
int j, ret;
int Next, Prev, Addr, SpaceSize, Mem_LB, Mem_RB, SelfAddr, Busy_Flag;
int All_Space;
All_Space = 0;
_BusyItemInfo = gcnew array<String^, 2>(i, 8);
for(j = 0; j < i; j++)
{
ret = Fun_RetBusyListItemInfo(j + 1, &Next, &Prev, &Addr, &SpaceSize, &Mem_LB, &Mem_RB, &SelfAddr, &Busy_Flag);
if(ret == 1)
{
All_Space += SpaceSize;
_BusyItemInfo[j, 0] = "Next:" + Next.ToString("X");
_BusyItemInfo[j, 1] = "Prev:" + Prev.ToString("X");
_BusyItemInfo[j, 2] = "Addr:" + Addr.ToString("X");
_BusyItemInfo[j, 3] = "Spac:" + SpaceSize.ToString();
_BusyItemInfo[j, 4] = "MeLb:" + Mem_LB.ToString("X");
_BusyItemInfo[j, 5] = "MeRb:" + Mem_RB.ToString("X");
_BusyItemInfo[j, 6] = "Self:" + SelfAddr.ToString("X");
_BusyItemInfo[j, 7] = "Busy:" + Busy_Flag.ToString("X");
}
}
All_Space -= i * 32;
if(All_Space != Test_Alloc_Mem)
{
this->textBox2->Text = "分配出大小與實(shí)際大小不同";
return;
}
int count;
count = Fun_AnalyseList(_BusyItemInfo, i, _ErrItem, _ErrItemInfo, _ErrItemPoint);
this->textBox2->Text = "發(fā)現(xiàn)錯(cuò)誤" + count.ToString() + "個(gè)";
if(count != 0)
{
this->checkBox2->Enabled = true;
}
else
{
this->checkBox2->Enabled = false;
}
_ErrCount = count;
}
}
///<summary>
///繪制出錯(cuò)鏈表Checked
///</summary>
private: System::Void checkBox2_CheckedChanged(System::Object^ sender, System::EventArgs^ e)
{
if(this->checkBox2->Checked == true)
{
_ErrPen = gcnew System::Drawing::Pen(Color::Black); //鏈表出錯(cuò)表項(xiàng)使用Pen
_ErrPen->EndCap = System::Drawing::Drawing2D::LineCap::ArrowAnchor;
_ErrPen->DashStyle = System::Drawing::Drawing2D::DashStyle::DashDotDot;
_ErrBrush = gcnew SolidBrush(Color::Black); //鏈表出錯(cuò)表項(xiàng)使用Bursh
Sub_DrawList(_ErrItem, _ErrItemPoint, _ErrPen, _ErrBrush, _ErrItemInfo, _BusyFont, _ErrCount);
}
}
///<summary>
///繪制空鏈表Checked
///</summary>
private: System::Void checkBox3_CheckedChanged(System::Object^ sender, System::EventArgs^ e)
{
if(this->checkBox3->Checked == false)
{
_myGraphics->Clear(this->pictureBox1->BackColor);
return;
}
int i;
!_IdleItem; //釋放
!_IdleItemPoint;
!_IdleItemInfo;
i = Fun_RetIdleList();
_IdleItemSum = i;
_IdleItem = gcnew array<Rectangle>(i);
_IdleItemPoint = gcnew array<Point,2>(i, 4);
_IdleItemInfo = gcnew array<String^, 2>(i, 8);
Sub_ComputerRectAndPoint(_IdleItem, _IdleItemPoint, Org_X, Org_Y, i);
int Next, Prev, Addr, SpaceSize, Mem_LB, Mem_RB, SelfAddr, BusyFlag;
int j, ret;
for(j = 0; j < i; j++)
{
ret = Fun_RetIDLEListItemInfo(j + 1, &Next, &Prev, &Addr, &SpaceSize, &Mem_LB, &Mem_RB, &SelfAddr, &BusyFlag);
if(ret == 1)
{
_IdleItemInfo[j, 0] = "Next:" + Next.ToString("X");
_IdleItemInfo[j, 1] = "Prev:" + Prev.ToString("X");
_IdleItemInfo[j, 2] = "Addr:" + Addr.ToString("X");
_IdleItemInfo[j, 3] = "Spac:" + SpaceSize.ToString();
_IdleItemInfo[j, 4] = "MeLb:" + Mem_LB.ToString("X");
_IdleItemInfo[j, 5] = "MeRb:" + Mem_RB.ToString("X");
_IdleItemInfo[j, 6] = "Self:" + SelfAddr.ToString("X");
_IdleItemInfo[j, 7] = "Busy:" + BusyFlag.ToString("X");
}
}
if(i == 1)
{
_myGraphics->FillRectangle(_IdleBrush, _IdleItem[0]);
}
else
{
Sub_DrawList(_IdleItem, _IdleItemPoint, _IdlePen, _IdleBrush, _IdleItemInfo, _BusyFont, i);
}
}
///<summary>
///隨機(jī)釋放內(nèi)存按鈕
///</summary>
private: System::Void button5_Click(System::Object^ sender, System::EventArgs^ e)
{
Random^ randObj = gcnew Random();
int i;
i = randObj->Next(0, Test_sp_num - 1);
Fun_Free((void *)Test_sp[i]);
Test_Alloc_Mem -= Test_Space[i];
Test_sp_num -= 1;
this->textBox1->Text = Test_sp_num.ToString();
int j;
for(j = i; j < Test_sp_num; j++)
{
Test_sp[j] = Test_sp[j + 1];
Test_Space[j] = Test_Space[j + 1];
}
}
///<summary>
///繪制物理內(nèi)存塊Checked
///</summary>
private: System::Void checkBox4_CheckedChanged(System::Object^ sender, System::EventArgs^ e)
{
if(this->checkBox4->Checked == false)
{
_myGraphics->Clear(this->pictureBox1->BackColor);
return;
}
_PhyCount = Fun_RetPhyList();
_PhyItem = gcnew array<Rectangle, 1>(_PhyCount); //物理鏈表中的表項(xiàng)數(shù)組
_PhyItemPoint = gcnew array<Point, 2>(_PhyCount, 4); //物理鏈表中的表項(xiàng)的4個(gè)關(guān)鍵點(diǎn)next,prev, next, prev
_PhyItemInfo = gcnew array<String^, 2>(_PhyCount, 8); //物理鏈表中的表項(xiàng)的關(guān)鍵信息
Sub_ComputerRectAndPoint(_PhyItem, _PhyItemPoint, Org_X, Org_Y, _PhyCount);
int Next, Prev, Addr, SpaceSize, Mem_LB, Mem_RB, SelfAddr, Busy_Flag;
int j, ret;
for(j = 0; j < _PhyCount; j++)
{
ret = Fun_RetPhyItemInfo(j + 1, &Next, &Prev, &Addr, &SpaceSize, &Mem_LB, &Mem_RB, &SelfAddr, &Busy_Flag);
_PhyItemInfo[j, 0] = "Next:" + Next.ToString("X");
_PhyItemInfo[j, 1] = "Prev:" + Prev.ToString("X");
_PhyItemInfo[j, 2] = "Addr:" + Addr.ToString("X");
_PhyItemInfo[j, 3] = "Spac:" + SpaceSize.ToString();
_PhyItemInfo[j, 4] = "MeLb:" + Mem_LB.ToString("X");
_PhyItemInfo[j, 5] = "MeRb:" + Mem_RB.ToString("X");
_PhyItemInfo[j, 6] = "Self:" + SelfAddr.ToString("X");
_PhyItemInfo[j, 7] = "Busy:" + Busy_Flag.ToString("X");
}
Sub_DrawPhyListItem(_PhyItem, _PhyItemPoint, _BusyPen, _BusyBrush, _IdlePen, _IdleBrush, _PhyItemInfo, _BusyFont, _PhyCount);
}
///<summary>
///分析空閑鏈表
///</summary>
private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e)
{
int i;
!_IdleItem; //釋放
!_IdleItemPoint;
!_IdleItemInfo;
i = Fun_RetIdleList();
_IdleItemSum = i;
_IdleItem = gcnew array<Rectangle>(i);
_IdleItemPoint = gcnew array<Point,2>(i, 4);
_IdleItemInfo = gcnew array<String^, 2>(i, 8);
Sub_ComputerRectAndPoint(_IdleItem, _IdleItemPoint, Org_X, Org_Y, i);
int Next, Prev, Addr, SpaceSize, Mem_LB, Mem_RB, SelfAddr, BusyFlag;
int j, ret;
for(j = 0; j < i; j++)
{
ret = Fun_RetIDLEListItemInfo(j + 1, &Next, &Prev, &Addr, &SpaceSize, &Mem_LB, &Mem_RB, &SelfAddr, &BusyFlag);
if(ret == 1)
{
_IdleItemInfo[j, 0] = "Next:" + Next.ToString("X");
_IdleItemInfo[j, 1] = "Prev:" + Prev.ToString("X");
_IdleItemInfo[j, 2] = "Addr:" + Addr.ToString("X");
_IdleItemInfo[j, 3] = "Spac:" + SpaceSize.ToString();
_IdleItemInfo[j, 4] = "MeLb:" + Mem_LB.ToString("X");
_IdleItemInfo[j, 5] = "MeRb:" + Mem_RB.ToString("X");
_IdleItemInfo[j, 6] = "Self:" + SelfAddr.ToString("X");
_IdleItemInfo[j, 7] = "Busy:" + BusyFlag.ToString("X");
}
}
UInt32 x1, errcount;
array<Char>^ xu_str = gcnew array<Char>(256);
String^ temp_str;
errcount = 0;
for(j = 0; j < i; j++)
{
xu_str->Clear(xu_str, 0, xu_str->GetLength(0));
_IdleItemInfo[j, 7]->CopyTo(5, xu_str, 0, _IdleItemInfo[j, 7]->Length - 5);
temp_str = gcnew String(xu_str);
x1 = System::UInt32::Parse(temp_str, System::Globalization::NumberStyles::AllowHexSpecifier);
if(x1 != 0)
{
errcount += 1;
}
}
this->textBox3->Text = "發(fā)現(xiàn)" + errcount.ToString() + "錯(cuò)誤";
}
///<summary>
///Mouse在PICBOX1中按下
///</summary>
private: System::Void pictureBox1_MouseClick(System::Object^ sender, System::Windows::Forms::MouseEventArgs^ e)
{
if(this->checkBox4->Checked == true)
{
int i;
for(i = 0; i < _PhyCount; i++)
{
if((e->X >= _PhyItem[i].X) && (e->X <= (_PhyItem[i].X + _PhyItem[i].Width)))
{
if((e->Y >= _PhyItem[i].Y) && (e->Y <= (_PhyItem[i].Y + _PhyItem[i].Height)))
{
UInt32 xx;
array<Char>^ xu_str = gcnew array<Char>(256);
String^ temp_str;
xu_str->Clear(xu_str, 0, xu_str->GetLength(0));
_PhyItemInfo[i, 7]->CopyTo(5, xu_str, 0, _PhyItemInfo[i, 7]->Length - 5);
temp_str = gcnew String(xu_str);
xx = System::UInt32::Parse(temp_str, System::Globalization::NumberStyles::AllowHexSpecifier);
if(xx != 0xaa)
{
return;
}
xu_str->Clear(xu_str, 0, xu_str->GetLength(0));
_PhyItemInfo[i, 2]->CopyTo(5, xu_str, 0, _PhyItemInfo[i, 2]->Length - 5);
temp_str = gcnew String(xu_str);
xx = System::UInt32::Parse(temp_str, System::Globalization::NumberStyles::AllowHexSpecifier);
for(i = 0; i < Test_sp_num; i++)
{
if(xx == (unsigned int)Test_sp[i])
{
break;
}
}
Fun_Free((void *)Test_sp[i]);
Test_Alloc_Mem -= Test_Space[i];
Test_sp_num -= 1;
this->textBox1->Text = Test_sp_num.ToString();
int j;
for(j = i; j < Test_sp_num; j++)
{
Test_sp[j] = Test_sp[j + 1];
Test_Space[j] = Test_Space[j + 1];
}
this->checkBox4->Checked = false;
this->checkBox4->Checked = true;
break;
}
}
}
}
}
};
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -