Exemple #1
0
static void
Game_mark(Game* game)
{
  if (game && !NIL_P(game->screen)) {
    rb_gc_mark(game->screen);
  }
}
Exemple #2
0
static int
vm_mark_each_thread_func(st_data_t key, st_data_t value, st_data_t dummy)
{
    VALUE thval = (VALUE)key;
    rb_gc_mark(thval);
    return ST_CONTINUE;
}
Exemple #3
0
static int
frame_mark_i(st_data_t key, st_data_t val, st_data_t arg)
{
    VALUE frame = (VALUE)key;
    rb_gc_mark(frame);
    return ST_CONTINUE;
}
Exemple #4
0
static void
context_mark(void *data)
{
  debug_context_t *context = (debug_context_t *) data;

  rb_gc_mark(context->backtrace);
}
Exemple #5
0
static void oci8_lob_mark(oci8_base_t *base)
{
    oci8_lob_t *lob = (oci8_lob_t *)base;
    if (lob->svcctx != NULL) {
        rb_gc_mark(lob->svcctx->base.self);
    }
}
Exemple #6
0
static void mark(xmlNodePtr node)
{
  /* it's OK if the document isn't fully realized (as in XML::Reader). */
  /* see http://github.com/tenderlove/nokogiri/issues/closed/#issue/95 */
  if (DOC_RUBY_OBJECT_TEST(node->doc) && DOC_RUBY_OBJECT(node->doc))
    rb_gc_mark(DOC_RUBY_OBJECT(node->doc));
}
Exemple #7
0
static void
rb_grn_database_mark_existing_ruby_object (grn_ctx *context, grn_obj *database)
{
    grn_table_cursor *cursor;
    grn_id id;

    cursor = grn_table_cursor_open(context, database, NULL, 0, NULL, 0,
				   0, -1, GRN_CURSOR_ASCENDING);
    if (!cursor)
	return;

    while ((id = grn_table_cursor_next(context, cursor)) != GRN_ID_NIL) {
	grn_obj *object;
	grn_user_data *user_data;
	RbGrnObject *rb_grn_object;

	object = grn_ctx_at(context, id);
	if (!object)
	    continue;
	user_data = grn_obj_user_data(context, object);
	if (!user_data)
	    continue;
	rb_grn_object = RB_GRN_OBJECT(user_data->ptr);
	if (!rb_grn_object)
	    continue;
	rb_gc_mark(rb_grn_object->self);
    }
    grn_table_cursor_close(context, cursor);
}
Exemple #8
0
static void
cont_mark(void *ptr)
{
    RUBY_MARK_ENTER("cont");
    if (ptr) {
	rb_context_t *cont = ptr;
	rb_gc_mark(cont->value);
	rb_thread_mark(&cont->saved_thread);

	if (cont->vm_stack) {
#ifdef CAPTURE_JUST_VALID_VM_STACK
	    rb_gc_mark_locations(cont->vm_stack,
				 cont->vm_stack + cont->vm_stack_slen + cont->vm_stack_clen);
#else
	    rb_gc_mark_localtion(cont->vm_stack,
				 cont->vm_stack, cont->saved_thread.stack_size);
#endif
	}

	if (cont->machine_stack) {
	    rb_gc_mark_locations(cont->machine_stack,
				 cont->machine_stack + cont->machine_stack_size);
	}
#ifdef __ia64
	if (cont->machine_register_stack) {
	    rb_gc_mark_locations(cont->machine_register_stack,
				 cont->machine_register_stack + cont->machine_register_stack_size);
	}
#endif
    }
    RUBY_MARK_LEAVE("cont");
}
Exemple #9
0
void helium_rb_callback(const helium_connection_t *conn, uint64_t sender_mac, char * const message, size_t n)
{
  struct helium_queued_callback queued = {
    .sender_mac = sender_mac,
    .message = malloc(n),
    .count = n,
    .conn = (helium_connection_t *)conn,
    .mutex = PTHREAD_MUTEX_INITIALIZER,
    .cond = PTHREAD_COND_INITIALIZER,
    .next = NULL
  };

  memcpy(queued.message, message, n);

  add_queued_callback(&queued);

  pthread_cond_signal(&g_callback_cond);

  pthread_mutex_lock(&queued.mutex);
  pthread_cond_wait(&queued.cond, &queued.mutex);
  pthread_mutex_unlock(&queued.mutex);
}

void helium_rb_mark(void * p) {
  helium_connection_t *conn = (helium_connection_t*)p;
  // make sure we mark the callback proc too so it doesn't get GCed
  rb_gc_mark(helium_get_context(conn));
}
Exemple #10
0
void
rb_vm_mark(void *ptr)
{
    int i;

    RUBY_MARK_ENTER("vm");
    RUBY_GC_INFO("-------------------------------------------------\n");
    if (ptr) {
	rb_vm_t *vm = ptr;
	if (vm->living_threads) {
	    st_foreach(vm->living_threads, vm_mark_each_thread_func, 0);
	}
	RUBY_MARK_UNLESS_NULL(vm->thgroup_default);
	RUBY_MARK_UNLESS_NULL(vm->mark_object_ary);
	RUBY_MARK_UNLESS_NULL(vm->load_path);
	RUBY_MARK_UNLESS_NULL(vm->loaded_features);
	RUBY_MARK_UNLESS_NULL(vm->top_self);
	RUBY_MARK_UNLESS_NULL(vm->coverages);
	rb_gc_mark_locations(vm->special_exceptions, vm->special_exceptions + ruby_special_error_count);

	if (vm->loading_table) {
	    rb_mark_tbl(vm->loading_table);
	}

	mark_event_hooks(vm->event_hooks);

	for (i = 0; i < RUBY_NSIG; i++) {
	    if (vm->trap_list[i].cmd)
		rb_gc_mark(vm->trap_list[i].cmd);
	}
    }

    RUBY_MARK_LEAVE("vm");
}
Exemple #11
0
static void
cont_mark(void *ptr)
{
    RUBY_MARK_ENTER("cont");
    if (ptr) {
	rb_context_t *cont = ptr;
	rb_gc_mark(cont->value);

	rb_thread_mark(&cont->saved_thread);
	rb_gc_mark(cont->saved_thread.self);

	if (cont->vm_stack) {
#ifdef CAPTURE_JUST_VALID_VM_STACK
	    rb_gc_mark_locations(cont->vm_stack,
				 cont->vm_stack + cont->vm_stack_slen + cont->vm_stack_clen);
#else
	    rb_gc_mark_locations(cont->vm_stack,
				 cont->vm_stack, cont->saved_thread.stack_size);
#endif
	}

	if (cont->machine.stack) {
	    if (cont->type == CONTINUATION_CONTEXT) {
		/* cont */
		rb_gc_mark_locations(cont->machine.stack,
				     cont->machine.stack + cont->machine.stack_size);
            }
            else {
		/* fiber */
		rb_thread_t *th;
                rb_fiber_t *fib = (rb_fiber_t*)cont;
		GetThreadPtr(cont->saved_thread.self, th);
		if ((th->fiber != fib) && fib->status == RUNNING) {
		    rb_gc_mark_locations(cont->machine.stack,
					 cont->machine.stack + cont->machine.stack_size);
		}
	    }
	}
#ifdef __ia64
	if (cont->machine.register_stack) {
	    rb_gc_mark_locations(cont->machine.register_stack,
				 cont->machine.register_stack + cont->machine.register_stack_size);
	}
#endif
    }
    RUBY_MARK_LEAVE("cont");
}
Exemple #12
0
static void
mark(struct png_data *reader)
{
    VALUE io = reader->io;

    if (io)
	rb_gc_mark(io);
}
void
cb_http_request_mark(void *ptr)
{
    struct cb_http_request_st *request = ptr;
    if (request) {
        rb_gc_mark(request->on_body_callback);
    }
}
Exemple #14
0
/*
 * Mark root object. (protect from GC)
 */
void
mark_root_object(void *ptr)
{
  VALUE value;
  if (ptr && st_lookup(root_table, (st_data_t)ptr, (st_data_t*)&value)) {
    rb_gc_mark(value);
  }
}
    void
cb_timer_mark(void *ptr)
{
    struct timer_st *timer = ptr;
    if (timer) {
        rb_gc_mark(timer->callback);
    }
}
Exemple #16
0
static void
mark_event_hooks(rb_event_hook_t *hook)
{
    while (hook) {
	rb_gc_mark(hook->data);
	hook = hook->next;
    }
}
Exemple #17
0
static void
location_mark(void *ptr)
{
    if (ptr) {
	struct valued_frame_info *vfi = (struct valued_frame_info *)ptr;
	rb_gc_mark(vfi->btobj);
    }
}
Exemple #18
0
static void
dlcfunc_mark(void *ptr)
{
    struct cfunc_data *data = ptr;
    if (data->wrap) {
	rb_gc_mark(data->wrap);
    }
}
Exemple #19
0
static void
mark_list(List *list)
{
    Entry *entry;
    for (entry = list->entries; entry; entry = entry->next) {
        rb_gc_mark(entry->value);
    }
}
static void c_CompletionResult_mark(void *s)
{
    if (s)
    {
        CompletionResult_t *t = (CompletionResult_t *) s;
        rb_gc_mark(t->parent);
    }
}
Exemple #21
0
/* GC helper functions */
void rbll_mark(ruby_liblicense *license) {
	rb_gc_mark(license->uri);
	rb_gc_mark(license->name);
	rb_gc_mark(license->jurisdiction);
	rb_gc_mark(license->version);
	rb_gc_mark(license->permits);
	rb_gc_mark(license->prohibits);
	rb_gc_mark(license->requires);
	rb_gc_mark(license->filename);
}
Exemple #22
0
static void
tree_mark(void *ptr)
{
  struct redtree *p = (struct redtree*)ptr;
  int idx, max = p->line_count;
  for (idx=0; idx < max; ++idx) {
    rb_gc_mark(p->lines[idx]);
  }
}
Exemple #23
0
static void parent_context_mark(redisParentContext *pc) {
    VALUE root;
    if (pc->context && pc->context->reader) {
        root = (VALUE)redisReplyReaderGetObject(pc->context->reader);
        if (root != 0 && TYPE(root) == T_ARRAY) {
            rb_gc_mark(root);
        }
    }
}
Exemple #24
0
static void mark_for_ruby_gc(DownpourWrapper *wrapper)
{
  if(wrapper == NULL)
    return;

  rb_gc_mark(wrapper->rb_object);

  mark_for_ruby_gc(wrapper->parent);
}
Exemple #25
0
static void
stackprof_gc_mark(void *data)
{
    if (RTEST(_stackprof.out))
	rb_gc_mark(_stackprof.out);

    if (_stackprof.frames)
	st_foreach(_stackprof.frames, frame_mark_i, 0);
}
Exemple #26
0
Fichier : task.c Projet : ko1/ptask
static void
task_mark(void *ptr)
{
    if (ptr) {
	rb_task_t *task = (rb_task_t *)ptr;
	int i;

	if (task->result != Qundef) {
	    rb_gc_mark(task->result);
	}

	if (task->argc > 0) {
	    for (i=0; i<task->argc; i++) {
		rb_gc_mark(task->argv[i]);
	    }
	}
    }
}
Exemple #27
0
/* Protects the mark object from GC */
static void grpc_rb_channel_mark(void *p) {
  grpc_rb_channel *channel = NULL;
  if (p == NULL) {
    return;
  }
  channel = (grpc_rb_channel *)p;
  if (channel->credentials != Qnil) {
    rb_gc_mark(channel->credentials);
  }
}
Exemple #28
0
void
vm_trace_mark_event_hooks(rb_hook_list_t *hooks)
{
    rb_event_hook_t *hook = hooks->hooks;

    while (hook) {
	rb_gc_mark(hook->data);
	hook = hook->next;
    }
}
Exemple #29
0
/* Protects the mark object from GC */
static void grpc_rb_server_mark(void *p) {
    grpc_rb_server *server = NULL;
    if (p == NULL) {
        return;
    }
    server = (grpc_rb_server *)p;
    if (server->mark != Qnil) {
        rb_gc_mark(server->mark);
    }
}
/* Protects the mark object from GC */
static void grpc_rb_call_credentials_mark(void* p) {
  grpc_rb_call_credentials* wrapper = NULL;
  if (p == NULL) {
    return;
  }
  wrapper = (grpc_rb_call_credentials*)p;
  if (wrapper->mark != Qnil) {
    rb_gc_mark(wrapper->mark);
  }
}