Changeset 26525 in vbox for trunk/src/VBox/Runtime/common
- Timestamp:
- Feb 15, 2010 3:33:33 AM (15 years ago)
- Location:
- trunk/src/VBox/Runtime/common
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/alloc/heapoffset.cpp
r26344 r26525 375 375 */ 376 376 AssertReturn(cbMemory >= PAGE_SIZE, VERR_INVALID_PARAMETER); 377 AssertReturn(cbMemory < UINT32_MAX, VERR_INVALID_PARAMETER); 377 378 AssertPtrReturn(pvMemory, VERR_INVALID_POINTER); 378 379 AssertReturn((uintptr_t)pvMemory + (cbMemory - 1) > (uintptr_t)cbMemory, VERR_INVALID_PARAMETER); … … 394 395 /* Init the heap anchor block. */ 395 396 pHeapInt->u32Magic = RTHEAPOFFSET_MAGIC; 396 pHeapInt->cbHeap = cbMemory;397 pHeapInt->cbFree = cbMemory397 pHeapInt->cbHeap = (uint32_t)cbMemory; 398 pHeapInt->cbFree = (uint32_t)cbMemory 398 399 - sizeof(RTHEAPOFFSETBLOCK) 399 400 - sizeof(RTHEAPOFFSETINTERNAL); -
trunk/src/VBox/Runtime/common/alloc/memcache.cpp
r26452 r26525 167 167 if (cbAlignment == 0) 168 168 { 169 cbAlignment = UINT32_C(1)<< ASMBitLastSetU32((uint32_t)cbObject);169 cbAlignment = (size_t)1 << ASMBitLastSetU32((uint32_t)cbObject); 170 170 if (cbAlignment > 64) 171 171 cbAlignment = 64; … … 191 191 192 192 pThis->u32Magic = RTMEMCACHE_MAGIC; 193 pThis->cbObject = RT_ALIGN_Z(cbObject, cbAlignment);194 pThis->cbAlignment = cbAlignment;195 pThis->cPerPage = ( PAGE_SIZE - RT_ALIGN_Z(sizeof(RTMEMCACHEPAGE), cbAlignment)) / pThis->cbObject;193 pThis->cbObject = (uint32_t)RT_ALIGN_Z(cbObject, cbAlignment); 194 pThis->cbAlignment = (uint32_t)cbAlignment; 195 pThis->cPerPage = (uint32_t)((PAGE_SIZE - RT_ALIGN_Z(sizeof(RTMEMCACHEPAGE), cbAlignment)) / pThis->cbObject); 196 196 while ( RT_ALIGN_Z(sizeof(RTMEMCACHEPAGE), RT_MIN(cbAlignment, 8)) 197 197 + pThis->cPerPage * pThis->cbObject -
trunk/src/VBox/Runtime/common/checksum/crc32-zlib.cpp
r21920 r26525 40 40 /** @todo Check if we can't just use the zlib code directly here. */ 41 41 42 /** 43 * Deal with blocks that are too big for the uInt type. 44 */ 45 static uint32_t rtCrc32ProcessTooBig(uint32_t uCRC32, const void *pv, size_t cb) 46 { 47 const Bytef *pb = (const Bytef *)pv; 48 do 49 { 50 uInt const cbChunk = cb <= ~(uInt)0 ? (uInt)cb : ~(uInt)0; 51 uCRC32 = crc32(uCRC32, pb, cbChunk); 52 pb += cbChunk; 53 cb -= cbChunk; 54 } while (!cb); 55 return uCRC32; 56 } 57 42 58 RTDECL(uint32_t) RTCrc32(const void *pv, register size_t cb) 43 59 { 44 60 uint32_t uCrc = crc32(0, NULL, 0); 45 return crc32(uCrc, (const Bytef *)pv, cb); 61 if (RT_UNLIKELY((uInt)cb == cb)) 62 uCrc = crc32(uCrc, (const Bytef *)pv, (uInt)cb); 63 else 64 uCrc = rtCrc32ProcessTooBig(uCrc, pv, cb); 65 return uCrc; 46 66 } 47 67 RT_EXPORT_SYMBOL(RTCrc32); … … 57 77 RTDECL(uint32_t) RTCrc32Process(uint32_t uCRC32, const void *pv, size_t cb) 58 78 { 59 return crc32(uCRC32, (const Bytef *)pv, cb); 79 if (RT_UNLIKELY((uInt)cb == cb)) 80 uCRC32 = crc32(uCRC32, (const Bytef *)pv, (uInt)cb); 81 else 82 uCRC32 = rtCrc32ProcessTooBig(uCRC32, pv, cb); 83 return uCRC32; 60 84 } 61 85 RT_EXPORT_SYMBOL(RTCrc32Process); -
trunk/src/VBox/Runtime/common/misc/getoptargv.cpp
r26478 r26525 87 87 return false; 88 88 default: 89 return memchr(pszSeparators, ch, cchSeparators) ;89 return memchr(pszSeparators, ch, cchSeparators) != NULL; 90 90 } 91 91 } -
trunk/src/VBox/Runtime/common/misc/s3.cpp
r25645 r26525 137 137 } 138 138 139 static char* rtS3ParseHeaders(char** ppHeaders, size_t cHead )139 static char* rtS3ParseHeaders(char** ppHeaders, size_t cHeadEnts) 140 140 { 141 141 char pszEmpty[] = ""; … … 143 143 char *pszDate = pszEmpty; 144 144 char *pszType = pszEmpty; 145 for(size_t i=0; i < cHead ; ++i)145 for(size_t i=0; i < cHeadEnts; ++i) 146 146 { 147 147 if(ppHeaders[i] != NULL) … … 171 171 } 172 172 173 static char* rtS3Canonicalize(const char* pszAction, const char* pszBucket, const char* pszKey, char** p pszHead, size_t cHead)173 static char* rtS3Canonicalize(const char* pszAction, const char* pszBucket, const char* pszKey, char** papszHeadEnts, size_t cHeadEnts) 174 174 { 175 175 char* pszRes; 176 176 /* Grep the necessary info out of the headers & put them in a string */ 177 char* pszHead = rtS3ParseHeaders(p pszHead, cHead);177 char* pszHead = rtS3ParseHeaders(papszHeadEnts, cHeadEnts); 178 178 /* Create the string which will be used as signature */ 179 179 RTStrAPrintf(&pszRes, "%s\n%s\n/", … … 199 199 } 200 200 201 static char* rtS3CreateSignature(PRTS3INTERNAL pS3Int, const char* pszAction, const char* pszBucket, const char* pszKey, char** ppszHead, size_t cHead) 201 static char* rtS3CreateSignature(PRTS3INTERNAL pS3Int, const char* pszAction, const char* pszBucket, const char* pszKey, 202 char** papszHeadEnts, size_t cHeadEnts) 202 203 { 203 204 /* Create a string we can sign */ 204 char* pszSig = rtS3Canonicalize(pszAction, pszBucket, pszKey, p pszHead, cHead);205 char* pszSig = rtS3Canonicalize(pszAction, pszBucket, pszKey, papszHeadEnts, cHeadEnts); 205 206 // printf ("Sig %s\n", pszSig); 206 207 /* Sign the string by creating a SHA1 finger print */ 207 208 char pszSigEnc[1024]; 208 209 unsigned int cSigEnc = sizeof(pszSigEnc); 209 HMAC(EVP_sha1(), pS3Int->pszSecretKey, strlen(pS3Int->pszSecretKey),210 HMAC(EVP_sha1(), pS3Int->pszSecretKey, (int)strlen(pS3Int->pszSecretKey), 210 211 (const unsigned char*)pszSig, strlen(pszSig), 211 212 (unsigned char*)pszSigEnc, &cSigEnc); … … 220 221 } 221 222 222 static char* rtS3CreateAuthHeader(PRTS3INTERNAL pS3Int, const char* pszAction, const char* pszBucket, const char* pszKey, char** ppszHead, size_t cHead) 223 static char* rtS3CreateAuthHeader(PRTS3INTERNAL pS3Int, const char* pszAction, const char* pszBucket, const char* pszKey, 224 char** papszHeadEnts, size_t cHeadEnts) 223 225 { 224 226 char *pszAuth; 225 227 /* Create a signature out of the header & the bucket/key info */ 226 char *pszSigBase64Enc = rtS3CreateSignature(pS3Int, pszAction, pszBucket, pszKey, p pszHead, cHead);228 char *pszSigBase64Enc = rtS3CreateSignature(pS3Int, pszAction, pszBucket, pszKey, papszHeadEnts, cHeadEnts); 227 229 /* Create the authorization header entry */ 228 230 RTStrAPrintf(&pszAuth, "Authorization: AWS %s:%s", … … 377 379 static int rtS3ReadXmlFromMemory(PRTS3TMPMEMCHUNK pChunk, const char* pszRootElement, xmlDocPtr *ppDoc, xmlNodePtr *ppCur) 378 380 { 379 *ppDoc = xmlReadMemory(pChunk->pszMem, pChunk->cSize, "", "ISO-8859-1", XML_PARSE_NOBLANKS);381 *ppDoc = xmlReadMemory(pChunk->pszMem, (int)pChunk->cSize, "", "ISO-8859-1", XML_PARSE_NOBLANKS); 380 382 if (*ppDoc == NULL) 381 383 return VERR_PARSE_ERROR; … … 566 568 567 569 /* Create the three basic header entries */ 568 char * ppszHead[3] =570 char *apszHead[3] = 569 571 { 570 572 rtS3HostHeader("", pS3Int->pszBaseUrl), /* Host entry */ … … 573 575 }; 574 576 /* Create the authorization header entry */ 575 ppszHead[RT_ELEMENTS(ppszHead)-1] = rtS3CreateAuthHeader(pS3Int, "GET", "", "", ppszHead, RT_ELEMENTS(ppszHead));577 apszHead[RT_ELEMENTS(apszHead)-1] = rtS3CreateAuthHeader(pS3Int, "GET", "", "", apszHead, RT_ELEMENTS(apszHead)); 576 578 577 579 /* Add all headers to curl */ 578 580 struct curl_slist* pHeaders = NULL; /* Init to NULL is important */ 579 for(size_t i=0; i < RT_ELEMENTS( ppszHead); ++i)580 pHeaders = curl_slist_append(pHeaders, ppszHead[i]);581 for(size_t i=0; i < RT_ELEMENTS(apszHead); ++i) 582 pHeaders = curl_slist_append(pHeaders, apszHead[i]); 581 583 582 584 /* Pass our list of custom made headers */ … … 592 594 /* Regardless of the result, free all used resources first*/ 593 595 curl_slist_free_all(pHeaders); 594 for(size_t i=0; i < RT_ELEMENTS( ppszHead); ++i)595 RTStrFree( ppszHead[i]);596 for(size_t i=0; i < RT_ELEMENTS(apszHead); ++i) 597 RTStrFree(apszHead[i]); 596 598 597 599 /* On success parse the result */ … … 645 647 646 648 /* Create the basic header entries */ 647 char * ppszHead[4] =649 char *apszHead[4] = 648 650 { 649 651 RTStrDup("Content-Length: 0"), /* Content length entry */ … … 653 655 }; 654 656 /* Create the authorization header entry */ 655 ppszHead[RT_ELEMENTS(ppszHead)-1] = rtS3CreateAuthHeader(pS3Int, "PUT", pszBucketName, "", ppszHead, RT_ELEMENTS(ppszHead));657 apszHead[RT_ELEMENTS(apszHead)-1] = rtS3CreateAuthHeader(pS3Int, "PUT", pszBucketName, "", apszHead, RT_ELEMENTS(apszHead)); 656 658 657 659 /* Add all headers to curl */ 658 660 struct curl_slist* pHeaders = NULL; /* Init to NULL is important */ 659 for(size_t i=0; i < RT_ELEMENTS( ppszHead); ++i)660 pHeaders = curl_slist_append(pHeaders, ppszHead[i]);661 for(size_t i=0; i < RT_ELEMENTS(apszHead); ++i) 662 pHeaders = curl_slist_append(pHeaders, apszHead[i]); 661 663 662 664 /* Pass our list of custom made headers */ … … 681 683 /* Regardless of the result, free all used resources first*/ 682 684 curl_slist_free_all(pHeaders); 683 for(size_t i=0; i < RT_ELEMENTS( ppszHead); ++i)684 RTStrFree( ppszHead[i]);685 for(size_t i=0; i < RT_ELEMENTS(apszHead); ++i) 686 RTStrFree(apszHead[i]); 685 687 686 688 return rc; … … 700 702 701 703 /* Create the three basic header entries */ 702 char * ppszHead[3] =704 char *apszHead[3] = 703 705 { 704 706 rtS3HostHeader(pszBucketName, pS3Int->pszBaseUrl), /* Host entry */ … … 707 709 }; 708 710 /* Create the authorization header entry */ 709 ppszHead[RT_ELEMENTS(ppszHead)-1] = rtS3CreateAuthHeader(pS3Int, "DELETE", pszBucketName, "", ppszHead, RT_ELEMENTS(ppszHead));711 apszHead[RT_ELEMENTS(apszHead)-1] = rtS3CreateAuthHeader(pS3Int, "DELETE", pszBucketName, "", apszHead, RT_ELEMENTS(apszHead)); 710 712 711 713 /* Add all headers to curl */ 712 714 struct curl_slist* pHeaders = NULL; /* Init to NULL is important */ 713 for(size_t i=0; i < RT_ELEMENTS( ppszHead); ++i)714 pHeaders = curl_slist_append(pHeaders, ppszHead[i]);715 for(size_t i=0; i < RT_ELEMENTS(apszHead); ++i) 716 pHeaders = curl_slist_append(pHeaders, apszHead[i]); 715 717 716 718 /* Pass our list of custom made headers */ … … 731 733 /* Regardless of the result, free all used resources first*/ 732 734 curl_slist_free_all(pHeaders); 733 for(size_t i=0; i < RT_ELEMENTS( ppszHead); ++i)734 RTStrFree( ppszHead[i]);735 for(size_t i=0; i < RT_ELEMENTS(apszHead); ++i) 736 RTStrFree(apszHead[i]); 735 737 736 738 return rc; … … 752 754 753 755 /* Create the three basic header entries */ 754 char * ppszHead[3] =756 char *apszHead[3] = 755 757 { 756 758 rtS3HostHeader(pszBucketName, pS3Int->pszBaseUrl), /* Host entry */ … … 759 761 }; 760 762 /* Create the authorization header entry */ 761 ppszHead[RT_ELEMENTS(ppszHead)-1] = rtS3CreateAuthHeader(pS3Int, "GET", pszBucketName, "", ppszHead, RT_ELEMENTS(ppszHead));763 apszHead[RT_ELEMENTS(apszHead)-1] = rtS3CreateAuthHeader(pS3Int, "GET", pszBucketName, "", apszHead, RT_ELEMENTS(apszHead)); 762 764 763 765 /* Add all headers to curl */ 764 766 struct curl_slist* pHeaders = NULL; /* Init to NULL is important */ 765 for(size_t i=0; i < RT_ELEMENTS( ppszHead); ++i)766 pHeaders = curl_slist_append(pHeaders, ppszHead[i]);767 for(size_t i=0; i < RT_ELEMENTS(apszHead); ++i) 768 pHeaders = curl_slist_append(pHeaders, apszHead[i]); 767 769 768 770 /* Pass our list of custom made headers */ … … 779 781 /* Regardless of the result, free all used resources first*/ 780 782 curl_slist_free_all(pHeaders); 781 for(size_t i=0; i < RT_ELEMENTS( ppszHead); ++i)782 RTStrFree( ppszHead[i]);783 for(size_t i=0; i < RT_ELEMENTS(apszHead); ++i) 784 RTStrFree(apszHead[i]); 783 785 784 786 /* On success parse the result */ … … 832 834 833 835 /* Create the three basic header entries */ 834 char * ppszHead[3] =836 char *apszHead[3] = 835 837 { 836 838 rtS3HostHeader(pszBucketName, pS3Int->pszBaseUrl), /* Host entry */ … … 839 841 }; 840 842 /* Create the authorization header entry */ 841 ppszHead[RT_ELEMENTS(ppszHead)-1] = rtS3CreateAuthHeader(pS3Int, "DELETE", pszBucketName, pszKeyName, ppszHead, RT_ELEMENTS(ppszHead));843 apszHead[RT_ELEMENTS(apszHead)-1] = rtS3CreateAuthHeader(pS3Int, "DELETE", pszBucketName, pszKeyName, apszHead, RT_ELEMENTS(apszHead)); 842 844 843 845 /* Add all headers to curl */ 844 846 struct curl_slist* pHeaders = NULL; /* Init to NULL is important */ 845 for(size_t i=0; i < RT_ELEMENTS( ppszHead); ++i)846 pHeaders = curl_slist_append(pHeaders, ppszHead[i]);847 for(size_t i=0; i < RT_ELEMENTS(apszHead); ++i) 848 pHeaders = curl_slist_append(pHeaders, apszHead[i]); 847 849 848 850 /* Pass our list of custom made headers */ … … 857 859 /* Regardless of the result, free all used resources first*/ 858 860 curl_slist_free_all(pHeaders); 859 for(size_t i=0; i < RT_ELEMENTS( ppszHead); ++i)860 RTStrFree( ppszHead[i]);861 for(size_t i=0; i < RT_ELEMENTS(apszHead); ++i) 862 RTStrFree(apszHead[i]); 861 863 862 864 return rc; … … 882 884 883 885 /* Create the three basic header entries */ 884 char * ppszHead[3] =886 char *apszHead[3] = 885 887 { 886 888 rtS3HostHeader(pszBucketName, pS3Int->pszBaseUrl), /* Host entry */ … … 889 891 }; 890 892 /* Create the authorization header entry */ 891 ppszHead[RT_ELEMENTS(ppszHead)-1] = rtS3CreateAuthHeader(pS3Int, "GET", pszBucketName, pszKeyName, ppszHead, RT_ELEMENTS(ppszHead));893 apszHead[RT_ELEMENTS(apszHead)-1] = rtS3CreateAuthHeader(pS3Int, "GET", pszBucketName, pszKeyName, apszHead, RT_ELEMENTS(apszHead)); 892 894 893 895 /* Add all headers to curl */ 894 896 struct curl_slist* pHeaders = NULL; /* Init to NULL is important */ 895 for(size_t i=0; i < RT_ELEMENTS( ppszHead); ++i)896 pHeaders = curl_slist_append(pHeaders, ppszHead[i]);897 for(size_t i=0; i < RT_ELEMENTS(apszHead); ++i) 898 pHeaders = curl_slist_append(pHeaders, apszHead[i]); 897 899 898 900 /* Pass our list of custom made headers */ … … 908 910 /* Regardless of the result, free all used resources first*/ 909 911 curl_slist_free_all(pHeaders); 910 for(size_t i=0; i < RT_ELEMENTS( ppszHead); ++i)911 RTStrFree( ppszHead[i]);912 for(size_t i=0; i < RT_ELEMENTS(apszHead); ++i) 913 RTStrFree(apszHead[i]); 912 914 913 915 /* Close the open file */ … … 950 952 RTStrAPrintf(&pszContentLength, "Content-Length: %lu", cbFileSize); 951 953 /* Create the three basic header entries */ 952 char * ppszHead[5] =954 char *apszHead[5] = 953 955 { 954 956 /* todo: For now we use octet-stream for all types. Later we should try … … 962 964 }; 963 965 /* Create the authorization header entry */ 964 ppszHead[RT_ELEMENTS(ppszHead)-1] = rtS3CreateAuthHeader(pS3Int, "PUT", pszBucketName, pszKeyName, ppszHead, RT_ELEMENTS(ppszHead));966 apszHead[RT_ELEMENTS(apszHead)-1] = rtS3CreateAuthHeader(pS3Int, "PUT", pszBucketName, pszKeyName, apszHead, RT_ELEMENTS(apszHead)); 965 967 966 968 /* Add all headers to curl */ 967 969 struct curl_slist* pHeaders = NULL; /* Init to NULL is important */ 968 for(size_t i=0; i < RT_ELEMENTS( ppszHead); ++i)969 pHeaders = curl_slist_append(pHeaders, ppszHead[i]);970 for(size_t i=0; i < RT_ELEMENTS(apszHead); ++i) 971 pHeaders = curl_slist_append(pHeaders, apszHead[i]); 970 972 971 973 /* Pass our list of custom made headers */ … … 988 990 /* Regardless of the result, free all used resources first*/ 989 991 curl_slist_free_all(pHeaders); 990 for(size_t i=0; i < RT_ELEMENTS( ppszHead); ++i)991 RTStrFree( ppszHead[i]);992 for(size_t i=0; i < RT_ELEMENTS(apszHead); ++i) 993 RTStrFree(apszHead[i]); 992 994 993 995 /* Close the open file */ -
trunk/src/VBox/Runtime/common/misc/zip.cpp
r25000 r26525 1726 1726 # endif 1727 1727 1728 unsigned cbDstActual = lzf_compress(pvSrc, cbSrc, pvDst, cbDst);1728 unsigned cbDstActual = lzf_compress(pvSrc, (unsigned)cbSrc, pvDst, (unsigned)cbDst); /** @todo deal with size type overflows */ 1729 1729 if (RT_UNLIKELY(cbDstActual < 1)) 1730 1730 return VERR_BUFFER_OVERFLOW; … … 1818 1818 { 1819 1819 #ifdef RTZIP_USE_LZF 1820 unsigned cbDstActual = lzf_decompress(pvSrc, cbSrc, pvDst, cbDst);1820 unsigned cbDstActual = lzf_decompress(pvSrc, (unsigned)cbSrc, pvDst, (unsigned)cbDst); /** @todo deal with size type overflows */ 1821 1821 if (RT_UNLIKELY(cbDstActual < 1)) 1822 1822 {
Note:
See TracChangeset
for help on using the changeset viewer.