Skip to content

Commit

Permalink
Add a wrapper of grn_proc_alloc() for plugin
Browse files Browse the repository at this point in the history
grn_plugin_proc_alloc() is added.
  • Loading branch information
kou committed Oct 11, 2012
1 parent d546ec9 commit 3314fa9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
8 changes: 8 additions & 0 deletions include/groonga/plugin.h
Expand Up @@ -151,6 +151,14 @@ void grn_plugin_mutex_lock(grn_ctx *ctx, grn_plugin_mutex *mutex);
*/
void grn_plugin_mutex_unlock(grn_ctx *ctx, grn_plugin_mutex *mutex);

/*
grn_plugin_proc_alloc() allocates a `grn_obj` object.
You can use it in function that is registered as GRN_PROC_FUNCTION.
*/
grn_obj *grn_plugin_proc_alloc(grn_ctx *ctx, grn_user_data *user_data,
grn_id domain, grn_obj_flags flags);


#ifdef __cplusplus
}
#endif
Expand Down
7 changes: 7 additions & 0 deletions lib/plugin.c
Expand Up @@ -523,3 +523,10 @@ grn_plugin_mutex_unlock(grn_ctx *ctx, grn_plugin_mutex *mutex)
CRITICAL_SECTION_LEAVE(mutex->critical_section);
}
}

grn_obj *
grn_plugin_proc_alloc(grn_ctx *ctx, grn_user_data *user_data,
grn_id domain, grn_obj_flags flags)
{
return grn_proc_alloc(ctx, user_data, domain, flags);
}
4 changes: 1 addition & 3 deletions plugins/query_expanders/tsv.c
Expand Up @@ -20,8 +20,6 @@
/* groonga's internal headers: They should be removed. */
/* for grn_text_fgets() */
#include <str.h>
/* for GRN_PROC_ALLOC() */
#include <db.h>
/* for grn_win32_base_dir() */
#include <util.h>

Expand Down Expand Up @@ -185,7 +183,7 @@ func_query_expander_tsv(grn_ctx *ctx, int nargs, grn_obj **args,
rc = GRN_SUCCESS;
}

rc_object = GRN_PROC_ALLOC(GRN_DB_INT32, 0);
rc_object = grn_plugin_proc_alloc(ctx, user_data, GRN_DB_INT32, 0);
if (rc_object) {
GRN_INT32_SET(ctx, rc_object, rc);
}
Expand Down

0 comments on commit 3314fa9

Please sign in to comment.