An error in the book "data structures and algorithms under multiple tasks"

Source: Internet
Author: User

The following are the current errors. I believe there are still many problems that have not been found in the book. Please promptly raise new errors and I will fix them as soon as possible.

1. P52 page 15th Line Original"Returns the number 0 in the HOOK array."Changed to"Returns the serial number in the HOOK array when the result is successful."

2. Line 3 on page 53Returns the number 0 in the HOOK array."Changed to"Returns the serial number in the HOOK array when the result is successful."

3. The Xcopy () function code on pages P164 and P165 is incorrect. The correct code is as follows:

/** Copy all files in one directory and subdirectory to another directory

@ Param char * pszSrcDir-source directory to be copied
@ Param char * pszTargeDir-target directory
@ Param BOOL bOverWrite-overwrite flag; FALSE indicates Overwrite
@ Return void-None
*/
Void Xcopy (char * pszSrcDir, char * pszTargeDir, BOOL bOverWrite)
{
Char lBaseSearch [MAX_PATH];
HANDLE lhFile;
WIN32_FIND_DATA lfData;

Sprintf (lBaseSearch, "% s // *. *", pszSrcDir );
LhFile = FindFirstFile (lBaseSearch, & lfData );
If (lhFile = INVALID_HANDLE_VALUE ){
Return;
}
Do {
CreateDirectory (pszTargeDir, NULL );
If (! Strcmp (lfData. cFileName, ".") |
! Strcmp (lfData. cFileName ,"..")){
/* Skip. and... not processed */
Continue;
}
If (lfData. dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ){
/* Directory */
Char szBaseDir [MAX_PATH];
Char szTargeDir [MAX_PATH];

Sprintf (szBaseDir, "% s // % s", pszSrcDir, lfData. cFileName );
Sprintf (szTargeDir, "% s // % s", pszTargeDir, lfData. cFileName );
Xcopy (szBaseDir, szTargeDir, bOverWrite );
}
Else {
/* Common File */
Char szBaseDir [MAX_PATH];
Char szTargeDir [MAX_PATH];

Sprintf (szBaseDir, "% s // % s", pszSrcDir, lfData. cFileName );
Sprintf (szTargeDir, "% s // % s", pszTargeDir, lfData. cFileName );

CopyFile (szBaseDir, szTargeDir, bOverWrite );
}
} While (FindNextFile (lhFile, & lfData ));
FindClose (lhFile );
}

4. The original Article"Where will the sending operation be blocked?" After modification,The sending operation is blocked."

5. P203 page 22nd ~ The 29 lines are as follows:

If (pDelNode = pANode-> pLeft)
{
PANode-> nMagic-= 1;
}
Else
{
Panode-> nmagic + = 1;
}
You need to move this code between lines 9th and 10th on the P203 page, and the modified 9th ~ The 21 lines of code are:

Pnode-> pdata = pdelnode-> pdata;
If (pdelnode = panode-> pleft)
{
Panode-> nmagic-= 1;
}
Else
{
Panode-> nmagic + = 1;
}
If (pDelNode! = PNode-> pLeft)
{
PANode-> pRight = pDelNode-> pLeft;
}

6, P265 page countdown 7th Lines Original"While (pCursor = NULL) " You need to insert the following two lines of code between the last 8th lines and the last 7th lines:If (pCursor = NULL)
{
P266 page 11th Line Original "pData = pCursor-> pData ;" You need to insert a right Braces Between lines 10th and 11."}"

 7. P343: The last 12th lines"For (I = 0; I <uSpaceCount; I ++ )"

Changed:"For (I = 0; I <uSpaceCount-1; I ++ )"

  P343 page bottom 5th Lines Original"PNode-> pNext = NULL ;" Insert a row after the last 5th rows"PNode-> uPos = uPos ;" 8. P34 page 16th Lines Original"UINT uHead ;" Insert a row after the first row"Void * pData ;" P34 page: 12th lines down, original"If (pBlock-> uHead = pBlock-> uTail )" Insert the following line of code before the last 12th rows:PData = pBlock-> ppData [uHead]; P34 page bottom 3rd Lines Original"Return pBlock-> ppData [uHead];" Changed:"Return pData ;" 9. Lines 146th in the DeQueue. c file under the cd capi directory (in the DeQue_Destroy () function) Original article:"For (I = pQue-> pFirst-> uMapPos; I <= pQue-> pLast-> uMapPos; I ++ )" Change the code to the following four lines:Uint ustart, uend; ustart = pque-> pfirst-> umappos; uend = pque-> plast-> umappos; for (I = ustart; I <= uend; I ++) 10. In the DSpaceList. c file under the CAPI directory of the CD (the code in this section is inconsistent with that on the CD, which shall prevail on the CD) The first line of the file"Pdsnode-> uinlistflag = dspacenode_not_in_list ;" You need to insert the following code between lines 140th and 141:Else {pList-> pTail = NULL ;} 253rd lines of original"If (pDSNode-> pSpList-> uFreeCount = pList-> uDataCount" Changed:"If (pDSNode-> pSpList-> uFreeCount = pList-> uDataCount-1" 262nd lines of original"/* Delete this node from the two-way linked list */" Insert the following two lines of code before row 262:If (pDSNode-> uInListFlag = DSPACENODE_IN_LIST ){ 270th lines of original"If (pList-> pHead = pDSNode )" Change to:"If (pList-> pHead = pDSNode )" 278th lines of original"/* Add pDSNode to the unused linked list with pEmpty as the header node */" Insert a right braces before the first row as a row."}"

11 , P111 Page penultimate 9 Line Original"Memcpy (pNode-> pData, pData, uDataLen );" In the penultimate 9 Insert the following line of code before the row:PNode-> pData = (void *) (char *) pNode + sizeof (SINGLENODE )); 12 , CD CAPI Directory Queue. c The 72 Line ( Queue_Destroy () Function)
Original :"If (pQueue-> uHead <pQueue-> uTail )"
Change :"If (pQueue-> uHead> pQueue-> uTail )" 13 14. The last 6th lines on the P8 page, original"Sizeof (pszMsg )", Change: "MSG_COUNT"

, CDCAPIDirectoryDeQue. cThe57Line (DeQueBlock_Destroy ()Function)
Original:"If (pQueue-> uHead <pQueue-> uTail )"
Modify"If (pQueue-> uHead> pQueue-> uTail )"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.