void grn_query_logger_init(void) { grn_memcpy(¤t_query_logger, &default_query_logger, sizeof(grn_query_logger)); CRITICAL_SECTION_INIT(default_query_logger_lock); }
void SafeMallocInit(void){ #ifdef WIN32 CRITICAL_SECTION_INIT(AllocCS, 128); #else CREATE_SPIN(AllocSpin); #endif /* WIN32 */ }
void grn_logger_init(void) { CRITICAL_SECTION_INIT(default_logger_lock); if (!current_logger.log) { grn_memcpy(¤t_logger, &default_logger, sizeof(grn_logger)); } }
grn_rc grn_plugins_init(void) { CRITICAL_SECTION_INIT(grn_plugins_lock); grn_plugins = grn_hash_create(&grn_gctx, NULL, PATH_MAX, sizeof(grn_plugin *), GRN_OBJ_KEY_VAR_SIZE); if (!grn_plugins) { return GRN_NO_MEMORY_AVAILABLE; } return GRN_SUCCESS; }
/* This function initializes a plugin. This function fails if there is no dictionary that uses the context encoding of groonga. */ grn_rc GRN_PLUGIN_INIT(grn_ctx *ctx) { sole_mecab = NULL; CRITICAL_SECTION_INIT(sole_mecab_lock); check_mecab_dictionary_encoding(ctx); return ctx->rc; }
static grn_rc grn_ctx_impl_init(grn_ctx *ctx) { grn_io_mapinfo mi; if (!(ctx->impl = grn_io_anon_map(ctx, &mi, IMPL_SIZE))) { return ctx->rc; } grn_alloc_init_ctx_impl(ctx); ctx->impl->encoding = ctx->encoding; ctx->impl->lifoseg = -1; ctx->impl->currseg = -1; CRITICAL_SECTION_INIT(ctx->impl->lock); if (!(ctx->impl->values = grn_array_create(ctx, NULL, sizeof(grn_db_obj *), GRN_ARRAY_TINY))) { CRITICAL_SECTION_FIN(ctx->impl->lock); grn_io_anon_unmap(ctx, &mi, IMPL_SIZE); ctx->impl = NULL; return ctx->rc; } if (!(ctx->impl->temporary_columns = grn_pat_create(ctx, NULL, GRN_TABLE_MAX_KEY_SIZE, sizeof(grn_obj *), 0))) { grn_array_close(ctx, ctx->impl->values); CRITICAL_SECTION_FIN(ctx->impl->lock); grn_io_anon_unmap(ctx, &mi, IMPL_SIZE); ctx->impl = NULL; return ctx->rc; } if (!(ctx->impl->ios = grn_hash_create(ctx, NULL, GRN_TABLE_MAX_KEY_SIZE, sizeof(grn_io *), GRN_OBJ_KEY_VAR_SIZE|GRN_HASH_TINY))) { grn_array_close(ctx, ctx->impl->values); grn_pat_close(ctx, ctx->impl->temporary_columns); CRITICAL_SECTION_FIN(ctx->impl->lock); grn_io_anon_unmap(ctx, &mi, IMPL_SIZE); ctx->impl = NULL; return ctx->rc; } ctx->impl->db = NULL; ctx->impl->expr_vars = grn_hash_create(ctx, NULL, sizeof(grn_id), sizeof(grn_obj *), 0); ctx->impl->stack_curr = 0; ctx->impl->curr_expr = NULL; ctx->impl->qe_next = NULL; GRN_TEXT_INIT(&ctx->impl->current_request_id, 0); ctx->impl->current_request_timer_id = NULL; ctx->impl->parser = NULL; GRN_TEXT_INIT(&ctx->impl->output.names, GRN_OBJ_VECTOR); GRN_UINT32_INIT(&ctx->impl->output.levels, GRN_OBJ_VECTOR); if (ctx == &grn_gctx) { ctx->impl->command_version = GRN_COMMAND_VERSION_STABLE; } else { ctx->impl->command_version = grn_get_default_command_version(); } if (ctx == &grn_gctx) { ctx->impl->match_escalation_threshold = GRN_DEFAULT_MATCH_ESCALATION_THRESHOLD; } else { ctx->impl->match_escalation_threshold = grn_get_default_match_escalation_threshold(); } ctx->impl->finalizer = NULL; ctx->impl->com = NULL; ctx->impl->output.buf = grn_obj_open(ctx, GRN_BULK, 0, GRN_DB_TEXT); ctx->impl->output.func = NULL; ctx->impl->output.data.ptr = NULL; #ifdef GRN_WITH_MESSAGE_PACK msgpack_packer_init(&ctx->impl->output.msgpacker, ctx, grn_msgpack_buffer_write); #endif ctx->impl->tv.tv_sec = 0; ctx->impl->tv.tv_nsec = 0; ctx->impl->edge = NULL; grn_loader_init(&ctx->impl->loader); ctx->impl->plugin_path = NULL; GRN_TEXT_INIT(&ctx->impl->query_log_buf, 0); ctx->impl->previous_errbuf[0] = '\0'; ctx->impl->n_same_error_messages = 0; grn_ctx_impl_mrb_init(ctx); return ctx->rc; }