| 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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 } | 268 } |
| 269 #ifdef __cplusplus | 269 #ifdef __cplusplus |
| 270 } | 270 } |
| 271 #endif | 271 #endif |
| 272 #ifdef __cplusplus | 272 #ifdef __cplusplus |
| 273 extern "C" { | 273 extern "C" { |
| 274 #endif | 274 #endif |
| 275 FX_LPVOID FX_Random_MT_Start(FX_DWORD dwSeed) | 275 FX_LPVOID FX_Random_MT_Start(FX_DWORD dwSeed) |
| 276 { | 276 { |
| 277 FX_LPMTRANDOMCONTEXT pContext = FX_Alloc(FX_MTRANDOMCONTEXT, 1); | 277 FX_LPMTRANDOMCONTEXT pContext = FX_Alloc(FX_MTRANDOMCONTEXT, 1); |
| 278 if (!pContext) { |
| 279 return NULL; |
| 280 } |
| 278 pContext->mt[0] = dwSeed; | 281 pContext->mt[0] = dwSeed; |
| 279 FX_DWORD &i = pContext->mti; | 282 FX_DWORD &i = pContext->mti; |
| 280 FX_LPDWORD pBuf = pContext->mt; | 283 FX_LPDWORD pBuf = pContext->mt; |
| 281 for (i = 1; i < MT_N; i ++) { | 284 for (i = 1; i < MT_N; i ++) { |
| 282 pBuf[i] = (1812433253UL * (pBuf[i - 1] ^ (pBuf[i - 1] >> 30)) + i); | 285 pBuf[i] = (1812433253UL * (pBuf[i - 1] ^ (pBuf[i - 1] >> 30)) + i); |
| 283 } | 286 } |
| 284 pContext->bHaveSeed = TRUE; | 287 pContext->bHaveSeed = TRUE; |
| 285 return pContext; | 288 return pContext; |
| 286 } | 289 } |
| 287 FX_DWORD FX_Random_MT_Generate(FX_LPVOID pContext) | 290 FX_DWORD FX_Random_MT_Generate(FX_LPVOID pContext) |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 { | 376 { |
| 374 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 377 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
| 375 FX_GenerateCryptoRandom(pBuffer, iCount); | 378 FX_GenerateCryptoRandom(pBuffer, iCount); |
| 376 #else | 379 #else |
| 377 FX_Random_GenerateBase(pBuffer, iCount); | 380 FX_Random_GenerateBase(pBuffer, iCount); |
| 378 #endif | 381 #endif |
| 379 } | 382 } |
| 380 #ifdef __cplusplus | 383 #ifdef __cplusplus |
| 381 } | 384 } |
| 382 #endif | 385 #endif |
| OLD | NEW |