Skip to content

Instantly share code, notes, and snippets.

Created January 7, 2014 19:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/95c1ed54738f155fe977 to your computer and use it in GitHub Desktop.
Save anonymous/95c1ed54738f155fe977 to your computer and use it in GitHub Desktop.
void OID::init() {
static AtomicUInt inc = static_cast<unsigned>(
scoped_ptr<SecureRandom>(SecureRandom::create())->nextInt64());
{
unsigned t = (unsigned) time(0);
unsigned char *T = (unsigned char *) &t;
_time[0] = T[3]; // big endian order because we use memcmp() to compare OID's
_time[1] = T[2];
_time[2] = T[1];
_time[3] = T[0];
}
_machineAndPid = ourMachineAndPid;
{
int new_inc = inc++;
unsigned char *T = (unsigned char *) &new_inc;
_inc[0] = T[2];
_inc[1] = T[1];
_inc[2] = T[0];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment