Sha256: fdb701d8cd33c3ee955184d252593d6748633b52a012e6f81c3528b818f7c81e
Contents?: true
Size: 1.77 KB
Versions: 4
Compression:
Stored size: 1.77 KB
Contents
/* vim: ft=c et ts=8 sts=4 sw=4 cino= * * Copyright 2011, 2012 Couchbase, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "couchbase_ext.h" static void cb_context_mark(void *p, struct cb_bucket_st* bucket) { struct cb_context_st *ctx = p; rb_gc_mark(ctx->proc); rb_gc_mark(ctx->rv); rb_gc_mark(ctx->exception); rb_gc_mark(ctx->observe_options); rb_gc_mark(ctx->force_format); rb_gc_mark(ctx->operation); rb_gc_mark(ctx->headers_val); (void)bucket; } struct cb_context_st * cb_context_alloc(struct cb_bucket_st* bucket) { struct cb_context_st *ctx = calloc(1, sizeof(*ctx)); if (ctx == NULL) { rb_raise(cb_eClientNoMemoryError, "failed to allocate memory for context"); } cb_gc_protect_ptr(bucket, ctx, cb_context_mark); ctx->bucket = bucket; ctx->exception = Qnil; return ctx; } struct cb_context_st * cb_context_alloc_common(struct cb_bucket_st *bucket, VALUE proc, size_t nqueries) { struct cb_context_st *ctx = cb_context_alloc(bucket); ctx->proc = proc; ctx->nqueries = nqueries; if (!bucket->async) { ctx->rv = rb_hash_new(); } return ctx; } void cb_context_free(struct cb_context_st *ctx) { cb_gc_unprotect_ptr(ctx->bucket, ctx); free(ctx); }
Version data entries
4 entries across 4 versions & 1 rubygems