summaryrefslogtreecommitdiff
path: root/src/unstable/bitstring.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2012-05-22 17:15:40 +0000
committerMike Buland <eichlan@xagasoft.com>2012-05-22 17:15:40 +0000
commitce793e31f387c0715fa5b50c20e06510cc3e95ff (patch)
tree5b15972bdcbe7a26933e8158f52b29fb014dc421 /src/unstable/bitstring.cpp
parent2295579eb790d6eff6e54e84c01da6de10809a71 (diff)
downloadlibbu++-ce793e31f387c0715fa5b50c20e06510cc3e95ff.tar.gz
libbu++-ce793e31f387c0715fa5b50c20e06510cc3e95ff.tar.bz2
libbu++-ce793e31f387c0715fa5b50c20e06510cc3e95ff.tar.xz
libbu++-ce793e31f387c0715fa5b50c20e06510cc3e95ff.zip
Moved random to stable, just needs some minor tweaks. But it's already in use
in a couple of core components, including in tempFile name generation.
Diffstat (limited to 'src/unstable/bitstring.cpp')
-rw-r--r--src/unstable/bitstring.cpp10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/unstable/bitstring.cpp b/src/unstable/bitstring.cpp
index c32240c..9559aad 100644
--- a/src/unstable/bitstring.cpp
+++ b/src/unstable/bitstring.cpp
@@ -6,16 +6,12 @@
6 */ 6 */
7 7
8#include "bu/bitstring.h" 8#include "bu/bitstring.h"
9#include <stdlib.h> 9#include "bu/random.h"
10#include <stdio.h> 10#include <stdio.h>
11#include <string.h> 11#include <string.h>
12 12
13#include "bu/exceptionbase.h" 13#include "bu/exceptionbase.h"
14 14
15#ifdef _WIN32
16#define random() rand()
17#endif
18
19#define bitsToBytes( iBits ) (((iBits/8)+((iBits%8)?(1):(0)))); 15#define bitsToBytes( iBits ) (((iBits/8)+((iBits%8)?(1):(0))));
20 16
21Bu::BitString::BitString() 17Bu::BitString::BitString()
@@ -51,7 +47,7 @@ Bu::BitString::BitString( long iNewBits, bool bFillRandomly )
51 // I'll just use the low order byte) 47 // I'll just use the low order byte)
52 for( j = 0; j < iBytes; j++ ) 48 for( j = 0; j < iBytes; j++ )
53 { 49 {
54 caData[j] = (unsigned char)(random() & 0xFF); 50 caData[j] = (unsigned char)(Bu::Random::rand() & 0xFF);
55 } 51 }
56 } 52 }
57 else 53 else
@@ -413,7 +409,7 @@ void Bu::BitString::randomize()
413 { 409 {
414 for( int j = 0; j < iBytes; j++ ) 410 for( int j = 0; j < iBytes; j++ )
415 { 411 {
416 caData[j] = (unsigned char)(random() & 0xFF); 412 caData[j] = (unsigned char)(Bu::Random::rand() & 0xFF);
417 } 413 }
418 fixup(); 414 fixup();
419 } 415 }