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