summaryrefslogtreecommitdiff
path: root/Build/source/libs/poppler/poppler-src/goo/grandom.cc
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/poppler/poppler-src/goo/grandom.cc')
-rw-r--r--Build/source/libs/poppler/poppler-src/goo/grandom.cc70
1 files changed, 0 insertions, 70 deletions
diff --git a/Build/source/libs/poppler/poppler-src/goo/grandom.cc b/Build/source/libs/poppler/poppler-src/goo/grandom.cc
deleted file mode 100644
index 3171af85ec3..00000000000
--- a/Build/source/libs/poppler/poppler-src/goo/grandom.cc
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * grandom.cc
- *
- * This file is licensed under the GPLv2 or later
- *
- * Pseudo-random number generation
- *
- * Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it>
- */
-
-#include <config.h>
-#include "grandom.h"
-#include "gtypes.h"
-
-#ifdef HAVE_RAND_R // rand_r backend (POSIX)
-
-static GBool initialized = gFalse;
-
-#include <stdlib.h>
-#include <time.h>
-static unsigned int seed;
-
-static void initialize() {
- if (!initialized) {
- seed = time(nullptr);
- initialized = gTrue;
- }
-}
-
-void grandom_fill(Guchar *buff, int size)
-{
- initialize();
- while (size--)
- *buff++ = rand_r(&seed) % 256;
-}
-
-double grandom_double()
-{
- initialize();
- return rand_r(&seed) / (1 + (double)RAND_MAX);
-}
-
-#else // srand+rand backend (unsafe, because it may interfere with the application)
-
-static GBool initialized = gFalse;
-
-#include <stdlib.h>
-#include <time.h>
-
-static void initialize() {
- if (!initialized) {
- srand(time(nullptr));
- initialized = gTrue;
- }
-}
-
-void grandom_fill(Guchar *buff, int size)
-{
- initialize();
- while (size--)
- *buff++ = rand() % 256;
-}
-
-double grandom_double()
-{
- initialize();
- return rand() / (1 + (double)RAND_MAX);
-}
-
-#endif