OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "core/include/fxcrt/fx_basic.h" | 7 #include "core/include/fxcrt/fx_basic.h" |
8 #include "core/include/fxcrt/fx_ext.h" | 8 #include "core/include/fxcrt/fx_ext.h" |
9 #include "core/src/fxcrt/extension.h" | 9 #include "core/src/fxcrt/extension.h" |
10 | 10 |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 } | 252 } |
253 } else { | 253 } else { |
254 while (pStr < pStrEnd) { | 254 while (pStr < pStrEnd) { |
255 dwHashCode = 1313 * dwHashCode + *pStr++; | 255 dwHashCode = 1313 * dwHashCode + *pStr++; |
256 } | 256 } |
257 } | 257 } |
258 return dwHashCode; | 258 return dwHashCode; |
259 } | 259 } |
260 | 260 |
261 void* FX_Random_MT_Start(FX_DWORD dwSeed) { | 261 void* FX_Random_MT_Start(FX_DWORD dwSeed) { |
262 FX_LPMTRANDOMCONTEXT pContext = FX_Alloc(FX_MTRANDOMCONTEXT, 1); | 262 FX_MTRANDOMCONTEXT* pContext = FX_Alloc(FX_MTRANDOMCONTEXT, 1); |
263 pContext->mt[0] = dwSeed; | 263 pContext->mt[0] = dwSeed; |
264 FX_DWORD& i = pContext->mti; | 264 FX_DWORD& i = pContext->mti; |
265 FX_DWORD* pBuf = pContext->mt; | 265 FX_DWORD* pBuf = pContext->mt; |
266 for (i = 1; i < MT_N; i++) { | 266 for (i = 1; i < MT_N; i++) { |
267 pBuf[i] = (1812433253UL * (pBuf[i - 1] ^ (pBuf[i - 1] >> 30)) + i); | 267 pBuf[i] = (1812433253UL * (pBuf[i - 1] ^ (pBuf[i - 1] >> 30)) + i); |
268 } | 268 } |
269 pContext->bHaveSeed = TRUE; | 269 pContext->bHaveSeed = TRUE; |
270 return pContext; | 270 return pContext; |
271 } | 271 } |
272 FX_DWORD FX_Random_MT_Generate(void* pContext) { | 272 FX_DWORD FX_Random_MT_Generate(void* pContext) { |
273 FXSYS_assert(pContext); | 273 FXSYS_assert(pContext); |
274 FX_LPMTRANDOMCONTEXT pMTC = (FX_LPMTRANDOMCONTEXT)pContext; | 274 FX_MTRANDOMCONTEXT* pMTC = static_cast<FX_MTRANDOMCONTEXT*>(pContext); |
275 FX_DWORD v; | 275 FX_DWORD v; |
276 static FX_DWORD mag[2] = {0, MT_Matrix_A}; | 276 static FX_DWORD mag[2] = {0, MT_Matrix_A}; |
277 FX_DWORD& mti = pMTC->mti; | 277 FX_DWORD& mti = pMTC->mti; |
278 FX_DWORD* pBuf = pMTC->mt; | 278 FX_DWORD* pBuf = pMTC->mt; |
279 if ((int)mti < 0 || mti >= MT_N) { | 279 if ((int)mti < 0 || mti >= MT_N) { |
280 if (mti > MT_N && !pMTC->bHaveSeed) { | 280 if (mti > MT_N && !pMTC->bHaveSeed) { |
281 return 0; | 281 return 0; |
282 } | 282 } |
283 FX_DWORD kk; | 283 FX_DWORD kk; |
284 for (kk = 0; kk < MT_N - MT_M; kk++) { | 284 for (kk = 0; kk < MT_N - MT_M; kk++) { |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 b = ((const uint8_t*)pGUID)[i]; | 387 b = ((const uint8_t*)pGUID)[i]; |
388 *pBuf++ = gs_FX_pHexChars[b >> 4]; | 388 *pBuf++ = gs_FX_pHexChars[b >> 4]; |
389 *pBuf++ = gs_FX_pHexChars[b & 0x0F]; | 389 *pBuf++ = gs_FX_pHexChars[b & 0x0F]; |
390 if (bSeparator && (i == 3 || i == 5 || i == 7 || i == 9)) { | 390 if (bSeparator && (i == 3 || i == 5 || i == 7 || i == 9)) { |
391 *pBuf++ = L'-'; | 391 *pBuf++ = L'-'; |
392 } | 392 } |
393 } | 393 } |
394 bsStr.ReleaseBuffer(bSeparator ? 36 : 32); | 394 bsStr.ReleaseBuffer(bSeparator ? 36 : 32); |
395 } | 395 } |
396 #endif // PDF_ENABLE_XFA | 396 #endif // PDF_ENABLE_XFA |
OLD | NEW |