- Timestamp:
- Mar 6, 2012 1:24:29 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/checksum/manifest.cpp
r40329 r40374 451 451 AssertReturn(cFiles > 0, VERR_INVALID_PARAMETER); 452 452 453 /* Calculate the size necessary for the memory buffer. */454 size_t cbSize = 0;455 size_t cbMaxSize = 0;456 for (size_t i = 0; i < cFiles; ++i)457 {458 size_t cbTmp = strlen(RTPathFilename(paFiles[i].pszTestFile)) + strlen(paFiles[i].pszTestDigest) + 10;459 cbMaxSize = RT_MAX(cbMaxSize, cbTmp);460 cbSize += cbTmp;461 }462 463 /* Create the memory buffer */464 void *pvBuf = RTMemAlloc(cbSize);465 if (!pvBuf)466 return VERR_NO_MEMORY;467 468 /* Allocate a temporary string buffer. */469 char * pszTmp = RTStrAlloc(cbMaxSize + 1);470 size_t cbPos = 0;471 453 const char *pcszDigestType; 472 454 switch (enmDigestType) … … 479 461 default: return VERR_INVALID_PARAMETER; 480 462 } 463 464 /* Calculate the size necessary for the memory buffer. */ 465 size_t cbSize = 0; 466 size_t cbMaxSize = 0; 467 for (size_t i = 0; i < cFiles; ++i) 468 { 469 size_t cbTmp = strlen(RTPathFilename(paFiles[i].pszTestFile)) + strlen(paFiles[i].pszTestDigest) + 10; 470 cbMaxSize = RT_MAX(cbMaxSize, cbTmp); 471 cbSize += cbTmp; 472 } 473 474 /* Create the memory buffer */ 475 void *pvBuf = RTMemAlloc(cbSize); 476 if (!pvBuf) 477 return VERR_NO_MEMORY; 478 479 /* Allocate a temporary string buffer. */ 480 char *pszTmp = RTStrAlloc(cbMaxSize + 1); 481 if (!pszTmp) 482 { 483 RTMemFree(pvBuf); 484 return VERR_NO_MEMORY; 485 } 486 size_t cbPos = 0; 487 481 488 for (size_t i = 0; i < cFiles; ++i) 482 489 {
Note:
See TracChangeset
for help on using the changeset viewer.