本文整理汇总了C++中GRN_FREE函数的典型用法代码示例。如果您正苦于以下问题:C++ GRN_FREE函数的具体用法?C++ GRN_FREE怎么用?C++ GRN_FREE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GRN_FREE函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: grn_dat_open
grn_dat *
grn_dat_open(grn_ctx *ctx, const char *path)
{
if (path && (std::strlen(path) >= (PATH_MAX - (FILE_ID_LENGTH + 1)))) {
ERR(GRN_FILENAME_TOO_LONG, "too long path");
return NULL;
}
grn_dat * const dat = static_cast<grn_dat *>(GRN_MALLOC(sizeof(grn_dat)));
if (!dat) {
return NULL;
}
grn_dat_init(ctx, dat);
dat->io = grn_io_open(ctx, path, grn_io_auto);
if (!dat->io) {
GRN_FREE(dat);
return NULL;
}
dat->header = (struct grn_dat_header *)grn_io_header(dat->io);
if (!dat->header) {
grn_io_close(ctx, dat->io);
GRN_FREE(dat);
return NULL;
}
dat->file_id = dat->header->file_id;
dat->encoding = dat->header->encoding;
dat->obj.header.flags = dat->header->flags;
dat->tokenizer = grn_ctx_at(ctx, dat->header->tokenizer);
return dat;
}
开发者ID:mworrell,项目名称:groonga,代码行数:32,代码来源:dat.cpp
示例2: grn_snip_close_real
/* It should be renamed to grn_snip_close() and marked as internal.
* TODO: 3.0 */
grn_rc
grn_snip_close_real(grn_ctx *ctx, grn_snip *snip)
{
snip_cond *cond, *cond_end;
if (!snip) { return GRN_INVALID_ARGUMENT; }
GRN_API_ENTER;
if (snip->flags & GRN_SNIP_COPY_TAG) {
int i;
snip_cond *sc;
const char *dot = snip->defaultopentag, *dct = snip->defaultclosetag;
for (i = snip->cond_len, sc = snip->cond; i; i--, sc++) {
if (sc->opentag != dot) { GRN_FREE((void *)sc->opentag); }
if (sc->closetag != dct) { GRN_FREE((void *)sc->closetag); }
}
if (dot) { GRN_FREE((void *)dot); }
if (dct) { GRN_FREE((void *)dct); }
}
if (snip->nstr) {
grn_obj_close(ctx, snip->nstr);
}
for (cond = snip->cond, cond_end = cond + snip->cond_len;
cond < cond_end; cond++) {
grn_snip_cond_close(ctx, cond);
}
GRN_FREE(snip);
GRN_API_RETURN(GRN_SUCCESS);
}
开发者ID:ry05cga,项目名称:groonga,代码行数:29,代码来源:snip.c
示例3: mecab_fin
/*
This function finalizes a tokenization.
*/
static grn_obj *
mecab_fin(grn_ctx *ctx, int nargs, grn_obj **args, grn_user_data *user_data)
{
grn_mecab_tokenizer *token = user_data->ptr;
grn_str_close(ctx, token->nstr);
GRN_FREE(token->buf);
GRN_FREE(token);
return NULL;
}
开发者ID:firewood,项目名称:groonga,代码行数:12,代码来源:mecab.c
示例4: mecab_fin
static grn_rc
mecab_fin(grn_ctx *ctx, grn_obj *table, grn_proc_data *user_data)
{
grn_mecab_tokenizer *token = user_data->ptr;
// if (token->mecab) { mecab_destroy(token->mecab); }
grn_str_close(ctx, token->nstr);
GRN_FREE(token->buf);
GRN_FREE(token);
return GRN_SUCCESS;
}
开发者ID:ikdttr,项目名称:groonga,代码行数:10,代码来源:token.c
示例5: grn_ctx_impl_init
static void
grn_ctx_impl_init(grn_ctx *ctx)
{
if (!(ctx->impl = GRN_MALLOC(sizeof(struct _grn_ctx_impl)))) { return; }
if (!(ctx->impl->segs = grn_io_anon_map(ctx, &ctx->impl->mi,
sizeof(grn_io_mapinfo) * N_SEGMENTS))) {
GRN_FREE(ctx->impl);
ctx->impl = NULL;
return;
}
#ifdef USE_DYNAMIC_MALLOC_CHANGE
grn_ctx_impl_init_malloc(ctx);
#endif
if (!(ctx->impl->values = grn_array_create(ctx, NULL, sizeof(grn_tmp_db_obj),
GRN_ARRAY_TINY))) {
grn_io_anon_unmap(ctx, &ctx->impl->mi, sizeof(grn_io_mapinfo) * N_SEGMENTS);
GRN_FREE(ctx->impl);
ctx->impl = NULL;
return;
}
ctx->impl->encoding = ctx->encoding;
ctx->impl->lifoseg = -1;
ctx->impl->currseg = -1;
ctx->impl->db = NULL;
ctx->impl->qe = grn_hash_create(ctx, NULL, sizeof(grn_id), sizeof(void *), 0);
ctx->impl->stack_curr = 0;
ctx->impl->phs = NIL;
ctx->impl->code = NIL;
ctx->impl->dump = NIL;
ctx->impl->op = GRN_OP_T0LVL;
ctx->impl->args = NIL;
ctx->impl->envir = NIL;
ctx->impl->value = NIL;
ctx->impl->ncells = 0;
ctx->impl->n_entries = 0;
ctx->impl->seqno = 0;
ctx->impl->lseqno = 0;
ctx->impl->nbinds = 0;
ctx->impl->nunbinds = 0;
ctx->impl->feed_mode = grn_ql_atonce;
ctx->impl->cur = NULL;
ctx->impl->str_end = NULL;
ctx->impl->batchmode = 0;
ctx->impl->gc_verbose = 0;
ctx->impl->inbuf = NULL;
ctx->impl->co.mode = 0;
ctx->impl->co.func = NULL;
ctx->impl->objects = NULL;
ctx->impl->symbols = NULL;
ctx->impl->com = NULL;
ctx->impl->outbuf = grn_obj_open(ctx, GRN_BULK, 0, 0);
GRN_TEXT_INIT(&ctx->impl->subbuf, 0);
}
开发者ID:ikdttr,项目名称:groonga,代码行数:55,代码来源:ctx.c
示例6: grn_com_event_init
grn_rc
grn_com_event_init(grn_ctx *ctx, grn_com_event *ev, int max_nevents, int data_size)
{
ev->max_nevents = max_nevents;
if ((ev->hash = grn_hash_create(ctx, NULL, sizeof(grn_sock), data_size, 0))) {
MUTEX_INIT(ev->mutex);
COND_INIT(ev->cond);
GRN_COM_QUEUE_INIT(&ev->recv_old);
ev->msg_handler = NULL;
memset(&(ev->curr_edge_id), 0, sizeof(grn_com_addr));
ev->acceptor = NULL;
ev->opaque = NULL;
#ifndef USE_SELECT
# ifdef USE_EPOLL
if ((ev->events = GRN_MALLOC(sizeof(struct epoll_event) * max_nevents))) {
if ((ev->epfd = epoll_create(max_nevents)) != -1) {
goto exit;
} else {
SERR("epoll_create");
}
GRN_FREE(ev->events);
}
# else /* USE_EPOLL */
# ifdef USE_KQUEUE
if ((ev->events = GRN_MALLOC(sizeof(struct kevent) * max_nevents))) {
if ((ev->kqfd = kqueue()) != -1) {
goto exit;
} else {
SERR("kqueue");
}
GRN_FREE(ev->events);
}
# else /* USE_KQUEUE */
if ((ev->events = GRN_MALLOC(sizeof(struct pollfd) * max_nevents))) {
goto exit;
}
# endif /* USE_KQUEUE*/
# endif /* USE_EPOLL */
grn_hash_close(ctx, ev->hash);
ev->hash = NULL;
ev->events = NULL;
#else /* USE_SELECT */
goto exit;
#endif /* USE_SELECT */
}
exit :
return ctx->rc;
}
开发者ID:iwaim,项目名称:groonga,代码行数:48,代码来源:com.c
示例7: grn_ra_truncate
grn_rc
grn_ra_truncate(grn_ctx *ctx, grn_ra *ra)
{
grn_rc rc;
char *path;
unsigned int element_size;
if ((path = (char *)grn_io_path(ra->io)) && *path != '\0') {
if (!(path = GRN_STRDUP(path))) {
ERR(GRN_NO_MEMORY_AVAILABLE, "cannot duplicate path.");
return GRN_NO_MEMORY_AVAILABLE;
}
} else {
path = NULL;
}
element_size = ra->header->element_size;
if ((rc = grn_io_close(ctx, ra->io))) { goto exit; }
ra->io = NULL;
if (path && (rc = grn_io_remove(ctx, path))) { goto exit; }
if (!_grn_ra_create(ctx, ra, path, element_size)) {
rc = GRN_UNKNOWN_ERROR;
}
exit:
if (path) { GRN_FREE(path); }
return rc;
}
开发者ID:ueno,项目名称:groonga,代码行数:25,代码来源:store.c
示例8: delimited_init
static grn_obj *
delimited_init(grn_ctx *ctx, grn_obj *table, grn_user_data *user_data,
uint8_t *delimiter, uint32_t delimiter_len)
{
grn_obj *str;
int nflags = 0;
grn_delimited_tokenizer *token;
grn_obj_flags table_flags;
if (!(str = grn_ctx_pop(ctx))) {
ERR(GRN_INVALID_ARGUMENT, "missing argument");
return NULL;
}
if (!(token = GRN_MALLOC(sizeof(grn_delimited_tokenizer)))) { return NULL; }
user_data->ptr = token;
token->delimiter = delimiter;
token->delimiter_len = delimiter_len;
token->pos = 0;
grn_table_get_info(ctx, table, &table_flags, &token->encoding, NULL);
nflags |= (table_flags & GRN_OBJ_KEY_NORMALIZE);
if (!(token->nstr = grn_str_open_(ctx, GRN_TEXT_VALUE(str), GRN_TEXT_LEN(str),
nflags, token->encoding))) {
GRN_FREE(token);
ERR(GRN_TOKENIZER_ERROR, "grn_str_open failed at grn_token_open");
return NULL;
}
token->next = (unsigned char *)token->nstr->norm;
token->end = token->next + token->nstr->norm_blen;
token->len = token->nstr->length;
GRN_TEXT_INIT(&token->curr_, GRN_OBJ_DO_SHALLOW_COPY);
GRN_UINT32_INIT(&token->stat_, 0);
return NULL;
}
开发者ID:ryoqun,项目名称:groonga,代码行数:32,代码来源:token.c
示例9: grn_token_cursor_close_token_filters
static void
grn_token_cursor_close_token_filters(grn_ctx *ctx,
grn_token_cursor *token_cursor)
{
grn_obj *token_filters = token_cursor->token_filter.objects;
unsigned int i, n_token_filters;
if (token_filters) {
n_token_filters = GRN_BULK_VSIZE(token_filters) / sizeof(grn_obj *);
} else {
n_token_filters = 0;
}
if (n_token_filters == 0) {
return;
}
for (i = 0; i < n_token_filters; i++) {
grn_obj *token_filter_object = GRN_PTR_VALUE_AT(token_filters, i);
grn_proc *token_filter = (grn_proc *)token_filter_object;
void *data = token_cursor->token_filter.data[i];
token_filter->callbacks.token_filter.fin(ctx, data);
}
GRN_FREE(token_cursor->token_filter.data);
}
开发者ID:digideskio,项目名称:groonga,代码行数:26,代码来源:token_cursor.c
示例10: grn_string_close
grn_rc
grn_string_close(grn_ctx *ctx, grn_obj *string)
{
grn_rc rc;
grn_string *string_ = (grn_string *)string;
if (string_) {
if (string_->normalized) { GRN_FREE(string_->normalized); }
if (string_->ctypes) { GRN_FREE(string_->ctypes); }
if (string_->checks) { GRN_FREE(string_->checks); }
GRN_FREE(string);
rc = GRN_SUCCESS;
} else {
rc = GRN_INVALID_ARGUMENT;
}
return rc;
}
开发者ID:SunguckLee,项目名称:MariaDB-PageCompression,代码行数:16,代码来源:string.c
示例11: mrb_grn_table_group_raw
static mrb_value
mrb_grn_table_group_raw(mrb_state *mrb, mrb_value self)
{
grn_ctx *ctx = (grn_ctx *)mrb->ud;
grn_obj *table;
mrb_value mrb_keys;
grn_table_sort_key *keys;
int i, n_keys;
mrb_value mrb_result;
grn_table_group_result *result;
table = DATA_PTR(self);
mrb_get_args(mrb, "oo", &mrb_keys, &mrb_result);
mrb_keys = mrb_convert_type(mrb, mrb_keys,
MRB_TT_ARRAY, "Array", "to_ary");
n_keys = RARRAY_LEN(mrb_keys);
keys = GRN_MALLOCN(grn_table_sort_key, n_keys);
for (i = 0; i < n_keys; i++) {
memcpy(&(keys[i]),
DATA_PTR(RARRAY_PTR(mrb_keys)[i]),
sizeof(grn_table_sort_key));
}
result = DATA_PTR(mrb_result);
grn_table_group(ctx, table, keys, n_keys, result, 1);
GRN_FREE(keys);
grn_mrb_ctx_check(mrb);
return mrb_result;
}
开发者ID:Belxjander,项目名称:Asuna,代码行数:31,代码来源:mrb_table.c
示例12: grn_type_create
grn_obj *
grn_type_create(grn_ctx *ctx, const char *name, unsigned int name_size,
grn_obj_flags flags, unsigned int size)
{
grn_id id;
struct _grn_type *res = NULL;
grn_obj *db;
if (!ctx || !ctx->impl || !(db = ctx->impl->db)) {
ERR(GRN_INVALID_ARGUMENT, "db not initialized");
return NULL;
}
GRN_API_ENTER;
if (grn_db_check_name(ctx, name, name_size)) {
GRN_DB_CHECK_NAME_ERR("[type][create]", name, name_size);
GRN_API_RETURN(NULL);
}
if (!GRN_DB_P(db)) {
ERR(GRN_INVALID_ARGUMENT, "invalid db assigned");
GRN_API_RETURN(NULL);
}
id = grn_obj_register(ctx, db, name, name_size);
if (id && (res = GRN_MALLOC(sizeof(grn_db_obj)))) {
GRN_DB_OBJ_SET_TYPE(res, GRN_TYPE);
res->obj.header.flags = flags;
res->obj.header.domain = GRN_ID_NIL;
GRN_TYPE_SIZE(&res->obj) = size;
if (grn_db_obj_init(ctx, db, id, DB_OBJ(res))) {
// grn_obj_delete(ctx, db, id);
GRN_FREE(res);
GRN_API_RETURN(NULL);
}
}
GRN_API_RETURN((grn_obj *)res);
}
开发者ID:cosmo0920,项目名称:groonga,代码行数:34,代码来源:type.c
示例13: grn_ja_truncate
grn_rc
grn_ja_truncate(grn_ctx *ctx, grn_ja *ja)
{
grn_rc rc;
char *path;
unsigned int max_element_size;
uint32_t flags;
if ((path = (char *)grn_io_path(ja->io)) && *path != '\0') {
if (!(path = GRN_STRDUP(path))) {
ERR(GRN_NO_MEMORY_AVAILABLE, "cannot duplicate path.");
return GRN_NO_MEMORY_AVAILABLE;
}
} else {
path = NULL;
}
max_element_size = ja->header->max_element_size;
flags = ja->header->flags;
if ((rc = grn_io_close(ctx, ja->io))) { goto exit; }
ja->io = NULL;
if (path && (rc = grn_io_remove(ctx, path))) { goto exit; }
if (!_grn_ja_create(ctx, ja, path, max_element_size, flags)) {
rc = GRN_UNKNOWN_ERROR;
}
exit:
if (path) { GRN_FREE(path); }
return rc;
}
开发者ID:ueno,项目名称:groonga,代码行数:27,代码来源:store.c
示例14: ngram_fin
static grn_rc
ngram_fin(grn_ctx *ctx, grn_obj *table, grn_proc_data *user_data)
{
grn_ngram_tokenizer *token = user_data->ptr;
grn_str_close(ctx, token->nstr);
GRN_FREE(token);
return GRN_SUCCESS;
}
开发者ID:ikdttr,项目名称:groonga,代码行数:8,代码来源:token.c
示例15: uvector_fin
static grn_obj *
uvector_fin(grn_ctx *ctx, int nargs, grn_obj **args, grn_user_data *user_data)
{
grn_uvector_tokenizer *tokenizer = user_data->ptr;
grn_tokenizer_token_fin(ctx, &(tokenizer->token));
GRN_FREE(tokenizer);
return NULL;
}
开发者ID:henbow,项目名称:groonga,代码行数:8,代码来源:token.c
示例16: grn_dat_cursor_close
void
grn_dat_cursor_close(grn_ctx *ctx, grn_dat_cursor *c)
{
if (c) {
grn_dat_cursor_fin(ctx, c);
GRN_FREE(c);
}
}
开发者ID:mworrell,项目名称:groonga,代码行数:8,代码来源:dat.cpp
示例17: grn_dat_create
grn_dat *
grn_dat_create(grn_ctx *ctx, const char *path, uint32_t,
uint32_t, uint32_t flags)
{
if (path) {
if (path[0] == '\0') {
path = NULL;
} else if (std::strlen(path) >= (PATH_MAX - (FILE_ID_LENGTH + 1))) {
ERR(GRN_FILENAME_TOO_LONG, "too long path");
return NULL;
}
}
grn_dat * const dat = static_cast<grn_dat *>(GRN_MALLOC(sizeof(grn_dat)));
if (!dat) {
return NULL;
}
grn_dat_init(ctx, dat);
dat->obj.header.flags = flags;
dat->io = grn_io_create(ctx, path, sizeof(struct grn_dat_header),
4096, 0, grn_io_auto, GRN_IO_EXPIRE_SEGMENT);
if (!dat->io) {
GRN_FREE(dat);
return NULL;
}
grn_io_set_type(dat->io, GRN_TABLE_DAT_KEY);
dat->header = static_cast<struct grn_dat_header *>(grn_io_header(dat->io));
if (!dat->header) {
grn_io_close(ctx, dat->io);
grn_dat_remove_file(ctx, path);
GRN_FREE(dat);
return NULL;
}
const grn_encoding encoding = (ctx->encoding != GRN_ENC_DEFAULT) ?
ctx->encoding : grn_gctx.encoding;
dat->header->flags = flags;
dat->header->encoding = encoding;
dat->header->tokenizer = GRN_ID_NIL;
dat->header->file_id = 0;
dat->encoding = encoding;
dat->tokenizer = NULL;
return dat;
}
开发者ID:mworrell,项目名称:groonga,代码行数:45,代码来源:dat.cpp
示例18: ngram_fin
static grn_obj *
ngram_fin(grn_ctx *ctx, int nargs, grn_obj **args, grn_user_data *user_data)
{
grn_ngram_tokenizer *tokenizer = user_data->ptr;
grn_tokenizer_token_fin(ctx, &(tokenizer->token));
grn_tokenizer_query_close(ctx, tokenizer->query);
GRN_FREE(tokenizer);
return NULL;
}
开发者ID:henbow,项目名称:groonga,代码行数:9,代码来源:token.c
示例19: grn_ts_obj_cursor_close
/* grn_ts_obj_cursor_close() destroys a wrapper cursor. */
static grn_rc
grn_ts_obj_cursor_close(grn_ctx *ctx, grn_ts_obj_cursor *cursor)
{
if (cursor->obj) {
grn_obj_close(ctx, cursor->obj);
}
GRN_FREE(cursor);
return GRN_SUCCESS;
}
开发者ID:XLPE,项目名称:groonga,代码行数:10,代码来源:ts_cursor.c
示例20: grn_dat_close
grn_rc
grn_dat_close(grn_ctx *ctx, grn_dat *dat)
{
if (dat) {
grn_dat_fin(ctx, dat);
GRN_FREE(dat);
}
return GRN_SUCCESS;
}
开发者ID:mworrell,项目名称:groonga,代码行数:9,代码来源:dat.cpp
注:本文中的GRN_FREE函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论