+#if defined( LDAP_SLAPI )
+ if ( slapi_plugins_used ) {
+ slapi_int_free_object_extensions( SLAPI_X_EXT_OPERATION, op );
+ }
+#endif /* defined( LDAP_SLAPI ) */
+
+ if ( !BER_BVISNULL( &op->o_csn ) ) {
+ op->o_tmpfree( op->o_csn.bv_val, op->o_tmpmemctx );
+ BER_BVZERO( &op->o_csn );
+ }
+
+ opbuf = (OperationBuffer *) op;
+ memset( opbuf, 0, sizeof(*opbuf) );
+ op->o_hdr = &opbuf->ob_hdr;
+ op->o_controls = opbuf->ob_controls;
+
+ if ( ctx ) {
+ void *op2 = NULL;
+ ldap_pvt_thread_pool_setkey( ctx, (void *)slap_op_free,
+ op, slap_op_q_destroy, &op2, NULL );
+ LDAP_STAILQ_NEXT( op, o_next ) = op2;
+ } else {
+ ber_memfree_x( op, NULL );
+ }
+}
+
+void
+slap_op_time(time_t *t, int *nop)
+{
+ ldap_pvt_thread_mutex_lock( &slap_op_mutex );
+ *t = slap_get_time();
+ if ( *t == last_time ) {
+ *nop = ++last_incr;
+ } else {
+ last_time = *t;
+ last_incr = 0;
+ *nop = 0;
+ }
+ ldap_pvt_thread_mutex_unlock( &slap_op_mutex );