本文整理汇总了C++中ruby_xfree函数的典型用法代码示例。如果您正苦于以下问题:C++ ruby_xfree函数的具体用法?C++ ruby_xfree怎么用?C++ ruby_xfree使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ruby_xfree函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: rb_lzfx_compress
static VALUE rb_lzfx_compress(VALUE self, VALUE input) {
unsigned char *compressed, *data;
int out_length, data_length;
int retcode;
VALUE retval;
Check_Type(input, T_STRING);
data = StringValuePtr(input);
data_length = RSTRING_LEN(input);
if (data_length < 1) {
return Qnil;
}
out_length = data_length * COFFICIENT_OF_BUFFER;
compressed = malloc(out_length);
retcode = lzfx_compress(data, data_length, compressed, &out_length);
if(retcode < 0) {
ruby_xfree(compressed);
return Qnil;
}
retval = rb_str_new(compressed, out_length);
ruby_xfree(compressed);
return retval;
}
开发者ID:hmsk,项目名称:lzfx,代码行数:30,代码来源:lzfxruby.c
示例2: backtrace_free
static void
backtrace_free(void *ptr)
{
if (ptr) {
rb_backtrace_t *bt = (rb_backtrace_t *)ptr;
if (bt->backtrace) ruby_xfree(bt->backtrace_base);
ruby_xfree(bt);
}
}
开发者ID:sho-h,项目名称:ruby,代码行数:9,代码来源:vm_backtrace.c
示例3: xthread_fifo_free
static void
xthread_fifo_free(void *ptr)
{
xthread_fifo_t *fifo = (xthread_fifo_t*)ptr;
if (fifo->elements) {
ruby_xfree(fifo->elements);
}
ruby_xfree(ptr);
}
开发者ID:keiju,项目名称:xthread,代码行数:10,代码来源:fifo.c
示例4: cont_free
static void
cont_free(void *ptr)
{
RUBY_FREE_ENTER("cont");
if (ptr) {
rb_context_t *cont = ptr;
RUBY_FREE_UNLESS_NULL(cont->saved_thread.stack); fflush(stdout);
#if FIBER_USE_NATIVE
if (cont->type == CONTINUATION_CONTEXT) {
/* cont */
ruby_xfree(cont->ensure_array);
RUBY_FREE_UNLESS_NULL(cont->machine.stack);
}
else {
/* fiber */
rb_fiber_t *fib = (rb_fiber_t*)cont;
#ifdef _WIN32
if (GET_THREAD()->fiber != fib && cont->type != ROOT_FIBER_CONTEXT) {
/* don't delete root fiber handle */
rb_fiber_t *fib = (rb_fiber_t*)cont;
if (fib->fib_handle) {
DeleteFiber(fib->fib_handle);
}
}
#else /* not WIN32 */
if (GET_THREAD()->fiber != fib) {
rb_fiber_t *fib = (rb_fiber_t*)cont;
if (fib->ss_sp) {
if (cont->type == ROOT_FIBER_CONTEXT) {
rb_bug("Illegal root fiber parameter");
}
munmap((void*)fib->ss_sp, fib->ss_size);
}
}
else {
/* It may reached here when finalize */
/* TODO examine whether it is a bug */
/* rb_bug("cont_free: release self"); */
}
#endif
}
#else /* not FIBER_USE_NATIVE */
ruby_xfree(cont->ensure_array);
RUBY_FREE_UNLESS_NULL(cont->machine.stack);
#endif
#ifdef __ia64
RUBY_FREE_UNLESS_NULL(cont->machine.register_stack);
#endif
RUBY_FREE_UNLESS_NULL(cont->vm_stack);
/* free rb_cont_t or rb_fiber_t */
ruby_xfree(ptr);
}
RUBY_FREE_LEAVE("cont");
}
开发者ID:0x00evil,项目名称:ruby,代码行数:55,代码来源:cont.c
示例5: rb_smbdir_data_free
static void rb_smbdir_data_free(RB_SMBFILE_DATA *data)
{
RB_SMB_DEBUG("data=%p smbcctx=%p smbcfile=%p\n", data, data->smbcctx, data->smbcfile);
if (data->smbcfile != NULL) {
rb_smbdir_close_and_deref_by_data(data);
}
ruby_xfree(data->url);
ruby_xfree(data);
}
开发者ID:Larsonchik,项目名称:ruby-net-smb,代码行数:11,代码来源:smbdir.c
示例6: rxml_features
/*
* call-seq:
* XML.features -> ["feature", ..., "feature"]
*
* Obtains an array of strings representing features supported
* (and enabled) by the installed libxml.
*/
static VALUE rxml_features(VALUE klass)
{
VALUE arr, str;
int i, len = MAX_LIBXML_FEATURES_LEN;
char **list = NULL;
list = ALLOC_N(char *,MAX_LIBXML_FEATURES_LEN);
MEMZERO(list, char *, MAX_LIBXML_FEATURES_LEN);
arr = rb_ary_new();
if (xmlGetFeaturesList(&len, (const char **) list) == -1)
return Qnil;
for (i = 0; i < len; i++)
{
str = rb_str_new2((const char *) list[i]);
rb_gc_unregister_address(&str);
rb_ary_push(arr, str);
}
if (len == MAX_LIBXML_FEATURES_LEN)
rb_warn(
"Please contact [email protected] and ask to have the \"MAX_LIBXML_FEATURES_LEN increased\" because you could possibly be seeing an incomplete list");
ruby_xfree(list);
return (arr);
}
开发者ID:xml4r,项目名称:libxml-ruby,代码行数:34,代码来源:ruby_xml.c
示例7: rb_ShMemutex_free
void rb_ShMemutex_free(ShMemutex *ptr)
{
if(ptr)
ptr->~ShMemutex();
ruby_xfree(ptr);
}
开发者ID:zophos,项目名称:Rim,代码行数:7,代码来源:shmemutex_ruby.cpp
示例8: free_request
void
free_request(request *req)
{
uint32_t i;
header *h;
if(req->path){
free_buffer(req->path);
req->path = NULL;
}
if(req->uri){
free_buffer(req->uri);
req->uri = NULL;
}
if(req->query_string){
free_buffer(req->query_string);
req->query_string = NULL;
}
if(req->fragment){
free_buffer(req->fragment);
req->fragment = NULL;
}
for(i = 0; i < req->num_headers+1; i++){
h = req->headers[i];
if(h){
free_buffer(h->field);
free_buffer(h->value);
free_header(h);
req->headers[i] = NULL;
}
}
ruby_xfree(req);
}
开发者ID:henteko,项目名称:bossan,代码行数:32,代码来源:request.c
示例9: m_read
/*
* @overload read(count, is_stderr: false, timeout: -1)
* Read data from a channel.
* @since 0.1.0
* @param [Fixnum] count The count of bytes to be read.
* @param [Boolean] is_stderr Read from the stderr flow or not.
* @param [Fixnum] timeout A timeout in seconds. +-1+ means infinite timeout.
* @return [String] Data read from the channel.
* @see http://api.libssh.org/stable/group__libssh__channel.html
* ssh_channel_read_timeout
*/
static VALUE m_read(int argc, VALUE *argv, VALUE self) {
ChannelHolder *holder;
VALUE count, opts;
const ID table[] = {id_stderr, id_timeout};
VALUE kwvals[sizeof(table) / sizeof(*table)];
struct nogvl_read_args args;
VALUE ret;
TypedData_Get_Struct(self, ChannelHolder, &channel_type, holder);
rb_scan_args(argc, argv, "10:", &count, &opts);
Check_Type(count, T_FIXNUM);
rb_get_kwargs(opts, table, 0, 2, kwvals);
if (kwvals[0] == Qundef) {
args.is_stderr = 0;
} else {
args.is_stderr = RTEST(kwvals[0]) ? 1 : 0;
}
if (kwvals[1] == Qundef) {
args.timeout = -1;
} else {
Check_Type(kwvals[1], T_FIXNUM);
args.timeout = FIX2INT(kwvals[1]);
}
args.channel = holder->channel;
args.count = FIX2UINT(count);
args.buf = ALLOC_N(char, args.count);
rb_thread_call_without_gvl(nogvl_read, &args, RUBY_UBF_IO, NULL);
ret = rb_utf8_str_new(args.buf, args.rc);
ruby_xfree(args.buf);
return ret;
}
开发者ID:sorah,项目名称:libssh-ruby,代码行数:43,代码来源:channel.c
示例10: ruby_vm_destruct
int
ruby_vm_destruct(void *ptr)
{
RUBY_FREE_ENTER("vm");
if (ptr) {
rb_vm_t *vm = ptr;
rb_thread_t *th = vm->main_thread;
#if defined(ENABLE_VM_OBJSPACE) && ENABLE_VM_OBJSPACE
struct rb_objspace *objspace = vm->objspace;
#endif
rb_gc_force_recycle(vm->self);
vm->main_thread = 0;
if (th) {
thread_free(th);
}
if (vm->living_threads) {
st_free_table(vm->living_threads);
vm->living_threads = 0;
}
rb_thread_lock_unlock(&vm->global_vm_lock);
rb_thread_lock_destroy(&vm->global_vm_lock);
ruby_xfree(vm);
ruby_current_vm = 0;
#if defined(ENABLE_VM_OBJSPACE) && ENABLE_VM_OBJSPACE
if (objspace) {
rb_objspace_free(objspace);
}
#endif
}
RUBY_FREE_LEAVE("vm");
return 0;
}
开发者ID:qnighy,项目名称:ruby-1.9.2p0,代码行数:32,代码来源:vm.c
示例11: wsf_free_wrapper
static void WSF_CALL
wsf_free_wrapper (
axutil_allocator_t * allocator,
void *ptr)
{
ruby_xfree(ptr);
}
开发者ID:harunjuhasz,项目名称:wsf,代码行数:7,代码来源:wsf_util.c
示例12: close_conn
static void
close_conn(client_t *cli, picoev_loop* loop)
{
if(!cli->keep_alive){
picoev_del(loop, cli->fd);
clean_cli(cli);
close(cli->fd);
#ifdef DEBUG
printf("close fd %d \n", cli->fd);
#endif
ruby_xfree(cli);
}else{
clean_cli(cli);
disable_cork(cli);
cli->keep_alive = 1;
cli->environ = Qnil;
cli->http_status = Qnil;
cli->headers = Qnil;
cli->header_done = 0;
cli->body_type = BODY_TYPE_NONE;
cli->status_code = 0;
cli->response = Qnil;
cli->content_length_set = 0;
cli->content_length = 0;
cli->write_bytes = 0;
cli->response_closed = 0;
cli->bad_request_code = 0;
init_parser(cli, server_name, server_port);
}
}
开发者ID:henteko,项目名称:bossan,代码行数:30,代码来源:bossan_ext.c
示例13: free_sdbm
static void
free_sdbm(struct dbmdata *dbmp)
{
if (dbmp->di_dbm) sdbm_close(dbmp->di_dbm);
ruby_xfree(dbmp);
}
开发者ID:Chatto,项目名称:VGdesk,代码行数:7,代码来源:init.c
示例14: location_free
static void
location_free(void *ptr)
{
if (ptr) {
rb_backtrace_location_t *fi = (rb_backtrace_location_t *)ptr;
ruby_xfree(fi);
}
}
开发者ID:sho-h,项目名称:ruby,代码行数:8,代码来源:vm_backtrace.c
示例15: rb_blink1_free
/** :nodoc: */
void rb_blink1_free(struct Blink1Instance *ins) {
if(ins->opened == 1) {
blink1_close(ins->dev);
ins->opened = 0;
}
// free(ins);
ruby_xfree(ins);
}
开发者ID:GeoffTidey,项目名称:rb-blink1,代码行数:9,代码来源:blink1.c
示例16: rb_fiddle_free
/*
* call-seq: Fiddle.free(addr)
*
* Free the memory at address +addr+
*/
VALUE
rb_fiddle_free(VALUE self, VALUE addr)
{
void *ptr = NUM2PTR(addr);
ruby_xfree(ptr);
return Qnil;
}
开发者ID:Danylyuk,项目名称:first_app,代码行数:13,代码来源:fiddle.c
示例17: ossl_cipher_free
/*
* PRIVATE
*/
static void
ossl_cipher_free(EVP_CIPHER_CTX *ctx)
{
if (ctx) {
EVP_CIPHER_CTX_cleanup(ctx);
ruby_xfree(ctx);
}
}
开发者ID:AdamDotCom,项目名称:my-rvm,代码行数:11,代码来源:ossl_cipher.c
示例18: c_CompletionResult_struct_free
static void c_CompletionResult_struct_free(CompletionResult_t *s)
{
if (s)
{
ruby_xfree(s);
}
}
开发者ID:cedlemo,项目名称:ruby-clangc,代码行数:8,代码来源:class_CompletionResult.c
示例19: cState_array_nl_set
/*
* call-seq: array_nl=(array_nl)
*
* This string is put at the end of a line that holds a JSON array.
*/
static VALUE cState_array_nl_set(VALUE self, VALUE array_nl)
{
unsigned long len;
GET_STATE(self);
Check_Type(array_nl, T_STRING);
len = RSTRING_LEN(array_nl);
if (len == 0) {
if (state->array_nl) {
ruby_xfree(state->array_nl);
state->array_nl = NULL;
}
} else {
if (state->array_nl) ruby_xfree(state->array_nl);
state->array_nl = strdup(RSTRING_PTR(array_nl));
state->array_nl_len = len;
}
return Qnil;
}
开发者ID:1nueve,项目名称:MacRuby,代码行数:23,代码来源:generator.c
示例20: dir_free
// The free function to go with our allocation.
//
static void dir_free(NDirStruct* s){
if (s->chandle)
CloseHandle(s->chandle);
if (s->fhandle)
FindClose(s->fhandle);
ruby_xfree(s);
}
开发者ID:djberg96,项目名称:Nerva,代码行数:11,代码来源:nerva_dir.c
注:本文中的ruby_xfree函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论