Skip to content

Commit

Permalink
run ok
Browse files Browse the repository at this point in the history
  • Loading branch information
mason51 committed Sep 22, 2012
1 parent 2a4bf66 commit 4c0d4ea
Show file tree
Hide file tree
Showing 13 changed files with 14 additions and 11 deletions.
9 changes: 6 additions & 3 deletions BuddyMem.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ char* BuddyMem::BuddyMemMalloc(const unsigned int size)
LinkNode *usedNode = new LinkNode; LinkNode *usedNode = new LinkNode;
usedNode->address = pAlloc; usedNode->address = pAlloc;
usedNode->next = NULL; usedNode->next = NULL;
insertNodeToTableLinkList(m_usedTableLinkListArray,tableIndex,usedNode); //insertNodeToTableLinkList(m_usedTableLinkListArray,tableIndex,usedNode);
insertNodeToUsedableLinkList(tableIndex, usedNode);


//3、从链表头节点保存的内存空间拆分成新的节点,添加到empty表 //3、从链表头节点保存的内存空间拆分成新的节点,添加到empty表
int i = 0; int i = 0;
Expand All @@ -111,7 +112,8 @@ char* BuddyMem::BuddyMemMalloc(const unsigned int size)
emptyNode = new LinkNode; emptyNode = new LinkNode;
emptyNode->address = pInsert; emptyNode->address = pInsert;
emptyNode->next = NULL; emptyNode->next = NULL;
insertNodeToTableLinkList(m_emptyTableLinkListArray,i,emptyNode); //insertNodeToTableLinkList(m_emptyTableLinkListArray,i,emptyNode);
insertNodeToEmptyTableLinkList(i, emptyNode);
pInsert = pInsert + m_blockSize*getBlockAmountFromIndex(i); pInsert = pInsert + m_blockSize*getBlockAmountFromIndex(i);
} }


Expand Down Expand Up @@ -152,7 +154,8 @@ void BuddyMem::BuddyMemFree(char *pMem)
nodeFind->next = NULL; nodeFind->next = NULL;
memset(nodeFind->address, 0, m_blockSize*getBlockAmountFromIndex(index)); memset(nodeFind->address, 0, m_blockSize*getBlockAmountFromIndex(index));
//把该节点插入empty表中 //把该节点插入empty表中
insertNodeToTableLinkList(m_emptyTableLinkListArray,index,nodeFind); //insertNodeToTableLinkList(m_emptyTableLinkListArray,index,nodeFind);
insertNodeToEmptyTableLinkList(index, nodeFind);


} }


Expand Down
Binary file modified BuddyMem.ncb
Binary file not shown.
Binary file modified BuddyMem.opt
Binary file not shown.
12 changes: 6 additions & 6 deletions BuddyMem.plg
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@
--------------------Configuration: BuddyMem - Win32 Debug-------------------- --------------------Configuration: BuddyMem - Win32 Debug--------------------
</h3> </h3>
<h3>Command Lines</h3> <h3>Command Lines</h3>
Creating temporary file "H:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP152.tmp" with contents Creating temporary file "H:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP193.tmp" with contents
[ [
/nologo /MLd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR"Debug/" /Fp"Debug/BuddyMem.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c /nologo /MLd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR"Debug/" /Fp"Debug/BuddyMem.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c
"E:\project\BuddyMem\main.cpp" "E:\project\BuddyMem\BuddyMem.cpp"
] ]
Creating command line "cl.exe @H:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP152.tmp" Creating command line "cl.exe @H:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP193.tmp"
Creating temporary file "H:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP153.tmp" with contents Creating temporary file "H:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP194.tmp" with contents
[ [
kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:yes /pdb:"Debug/BuddyMem.pdb" /debug /machine:I386 /out:"Debug/BuddyMem.exe" /pdbtype:sept kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:yes /pdb:"Debug/BuddyMem.pdb" /debug /machine:I386 /out:"Debug/BuddyMem.exe" /pdbtype:sept
.\Debug\BuddyMem.obj .\Debug\BuddyMem.obj
.\Debug\main.obj .\Debug\main.obj
] ]
Creating command line "link.exe @H:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP153.tmp" Creating command line "link.exe @H:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP194.tmp"
<h3>Output Window</h3> <h3>Output Window</h3>
Compiling... Compiling...
main.cpp BuddyMem.cpp
Linking... Linking...
Creating command line "bscmake.exe /nologo /o"Debug/BuddyMem.bsc" .\Debug\BuddyMem.sbr .\Debug\main.sbr" Creating command line "bscmake.exe /nologo /o"Debug/BuddyMem.bsc" .\Debug\BuddyMem.sbr .\Debug\main.sbr"
Creating browse info file... Creating browse info file...
Expand Down
Binary file modified Debug/BuddyMem.bsc
Binary file not shown.
Binary file modified Debug/BuddyMem.exe
Binary file not shown.
Binary file modified Debug/BuddyMem.ilk
Binary file not shown.
Binary file modified Debug/BuddyMem.obj
Binary file not shown.
Binary file modified Debug/BuddyMem.pdb
Binary file not shown.
Binary file modified Debug/main.obj
Binary file not shown.
Binary file modified Debug/vc60.idb
Binary file not shown.
Binary file modified Debug/vc60.pdb
Binary file not shown.
4 changes: 2 additions & 2 deletions main.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ int main()
buddyMem.BuddyMemCreate(); buddyMem.BuddyMemCreate();
char *p1 = buddyMem.BuddyMemMalloc(3); char *p1 = buddyMem.BuddyMemMalloc(3);
buddyMem.BuddyMemFree(p1); buddyMem.BuddyMemFree(p1);
char *p2 = buddyMem.BuddyMemMalloc(33); //char *p2 = buddyMem.BuddyMemMalloc(33);
char *p3 = buddyMem.BuddyMemMalloc(33); //char *p3 = buddyMem.BuddyMemMalloc(33);
buddyMem.BuddyMemDestroy(); buddyMem.BuddyMemDestroy();


return 0; return 0;
Expand Down

0 comments on commit 4c0d4ea

Please sign in to comment.