mirror of
https://github.com/MariaDB/server.git
synced 2025-01-24 15:54:37 +01:00
ndb - use reentrant functions in HugoCalulator
ndb/test/src/HugoCalculator.cpp: Use reentrant function in HugoCalulator
This commit is contained in:
parent
41c1a6c658
commit
0eb1a8107f
1 changed files with 8 additions and 8 deletions
|
@ -72,13 +72,14 @@ HugoCalculator::Int64 calcValue(int record, int attrib, int updates) const;
|
|||
HugoCalculator::float calcValue(int record, int attrib, int updates) const;
|
||||
HugoCalculator::double calcValue(int record, int attrib, int updates) const;
|
||||
#endif
|
||||
|
||||
const char*
|
||||
HugoCalculator::calcValue(int record,
|
||||
int attrib,
|
||||
int updates,
|
||||
char* buf,
|
||||
int len) const {
|
||||
|
||||
unsigned seed;
|
||||
const NdbDictionary::Column* attr = m_tab.getColumn(attrib);
|
||||
Uint32 val;
|
||||
do
|
||||
|
@ -98,16 +99,15 @@ HugoCalculator::calcValue(int record,
|
|||
|
||||
if (attr->getPrimaryKey())
|
||||
{
|
||||
srand(record + attrib);
|
||||
val = (record + attrib);
|
||||
seed = record + attrib;
|
||||
}
|
||||
else
|
||||
{
|
||||
srand(record + attrib + updates);
|
||||
val = rand();
|
||||
seed = record + attrib + updates;
|
||||
}
|
||||
} while (0);
|
||||
|
||||
val = rand_r(&seed);
|
||||
|
||||
if(attr->getNullable() && (((val >> 16) & 255) > 220))
|
||||
return NULL;
|
||||
|
||||
|
@ -115,14 +115,14 @@ HugoCalculator::calcValue(int record,
|
|||
int pos= 4;
|
||||
while(pos + 4 < len)
|
||||
{
|
||||
val= rand();
|
||||
val= rand_r(&seed);
|
||||
memcpy(buf+pos, &val, 4);
|
||||
pos++;
|
||||
}
|
||||
|
||||
if(pos < len)
|
||||
{
|
||||
val= rand();
|
||||
val= rand_r(&seed);
|
||||
memcpy(buf+pos, &val, (len - pos));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue