| 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 "../../include/fxcrt/fx_ext.h" | 7 #include "../../include/fxcrt/fx_ext.h" |
| 8 #include "extension.h" | 8 #include "extension.h" |
| 9 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 9 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
| 10 #include <wincrypt.h> | 10 #include <wincrypt.h> |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 } | 280 } |
| 281 #ifdef __cplusplus | 281 #ifdef __cplusplus |
| 282 } | 282 } |
| 283 #endif | 283 #endif |
| 284 #ifdef __cplusplus | 284 #ifdef __cplusplus |
| 285 extern "C" { | 285 extern "C" { |
| 286 #endif | 286 #endif |
| 287 FX_LPVOID FX_Random_MT_Start(FX_DWORD dwSeed) | 287 FX_LPVOID FX_Random_MT_Start(FX_DWORD dwSeed) |
| 288 { | 288 { |
| 289 FX_LPMTRANDOMCONTEXT pContext = FX_Alloc(FX_MTRANDOMCONTEXT, 1); | 289 FX_LPMTRANDOMCONTEXT pContext = FX_Alloc(FX_MTRANDOMCONTEXT, 1); |
| 290 if (!pContext) { | |
| 291 return NULL; | |
| 292 } | |
| 293 pContext->mt[0] = dwSeed; | 290 pContext->mt[0] = dwSeed; |
| 294 FX_DWORD &i = pContext->mti; | 291 FX_DWORD &i = pContext->mti; |
| 295 FX_LPDWORD pBuf = pContext->mt; | 292 FX_LPDWORD pBuf = pContext->mt; |
| 296 for (i = 1; i < MT_N; i ++) { | 293 for (i = 1; i < MT_N; i ++) { |
| 297 pBuf[i] = (1812433253UL * (pBuf[i - 1] ^ (pBuf[i - 1] >> 30)) + i); | 294 pBuf[i] = (1812433253UL * (pBuf[i - 1] ^ (pBuf[i - 1] >> 30)) + i); |
| 298 } | 295 } |
| 299 pContext->bHaveSeed = TRUE; | 296 pContext->bHaveSeed = TRUE; |
| 300 return pContext; | 297 return pContext; |
| 301 } | 298 } |
| 302 FX_DWORD FX_Random_MT_Generate(FX_LPVOID pContext) | 299 FX_DWORD FX_Random_MT_Generate(FX_LPVOID pContext) |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 *pBuf ++ = gs_FX_pHexChars[b & 0x0F]; | 422 *pBuf ++ = gs_FX_pHexChars[b & 0x0F]; |
| 426 if (bSeparator && (i == 3 || i == 5 || i == 7 || i == 9)) { | 423 if (bSeparator && (i == 3 || i == 5 || i == 7 || i == 9)) { |
| 427 *pBuf ++ = L'-'; | 424 *pBuf ++ = L'-'; |
| 428 } | 425 } |
| 429 } | 426 } |
| 430 bsStr.ReleaseBuffer(bSeparator ? 36 : 32); | 427 bsStr.ReleaseBuffer(bSeparator ? 36 : 32); |
| 431 } | 428 } |
| 432 #ifdef __cplusplus | 429 #ifdef __cplusplus |
| 433 } | 430 } |
| 434 #endif | 431 #endif |
| OLD | NEW |