void bson_oid_init_sequence (bson_oid_t *oid, /* OUT */ bson_context_t *context) /* IN */ { uint32_t now = (uint32_t)(time (NULL)); if (!context) { context = bson_context_get_default (); } now = BSON_UINT32_TO_BE (now); memcpy (&oid->bytes[0], &now, sizeof (now)); context->oid_get_seq64 (context, oid); }
void bson_oid_init_sequence (bson_oid_t *oid, bson_context_t *context) { bson_uint32_t now = time(NULL); if (!context) { context = bson_context_get_default(); } now = BSON_UINT32_TO_BE(now); memcpy(&oid->bytes[0], &now, 4); context->oid_get_seq64(context, oid); }
void bson_oid_init (bson_oid_t *oid, bson_context_t *context) { bson_uint32_t now = time(NULL); bson_return_if_fail(oid); if (!context) { context = bson_context_get_default(); } now = BSON_UINT32_TO_BE(now); memcpy(&oid->bytes[0], &now, 4); context->oid_get_host(context, oid); context->oid_get_pid(context, oid); context->oid_get_seq32(context, oid); }
void bson_oid_init (bson_oid_t *oid, /* OUT */ bson_context_t *context) /* IN */ { uint32_t now = (uint32_t)(time (NULL)); bson_return_if_fail (oid); if (!context) { context = bson_context_get_default (); } now = BSON_UINT32_TO_BE (now); memcpy (&oid->bytes[0], &now, sizeof (now)); context->oid_get_host (context, oid); context->oid_get_pid (context, oid); context->oid_get_seq32 (context, oid); }
static void test_bson_oid_init (void) { bson_context_t *context; bson_oid_t oid; bson_oid_t oid2; int i; context = bson_context_new(BSON_CONTEXT_NONE); bson_oid_init(&oid, context); for (i = 0; i < 10000; i++) { bson_oid_init(&oid2, context); assert(FALSE == bson_oid_equal(&oid, &oid2)); assert(0 > bson_oid_compare(&oid, &oid2)); bson_oid_copy(&oid2, &oid); } bson_context_destroy(context); /* * Test that the shared context works. */ bson_oid_init(&oid, NULL); BSON_ASSERT(bson_context_get_default()); }