X-Git-Url: https://git.efficios.com/?a=blobdiff_plain;f=lib%2Fcontext.c;h=87901b3c61027aadea02e0ddf0f9aa042b4aaac1;hb=HEAD;hp=48cf216e11780f99a20b6dea27264368c9c350c3;hpb=842c2b97eab577484edae763770dfd1440490818;p=babeltrace.git diff --git a/lib/context.c b/lib/context.c deleted file mode 100644 index 48cf216e..00000000 --- a/lib/context.c +++ /dev/null @@ -1,77 +0,0 @@ -/* - * context.c - * - * Babeltrace Library - * - * Copyright 2011-2012 EfficiOS Inc. and Linux Foundation - * - * Author: Mathieu Desnoyers - * Julien Desfossez - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - */ - -#include -#include -#include - -struct bt_context *bt_context_create(struct trace_collection *tc) -{ - struct bt_context *ctx; - - ctx = calloc(1, sizeof(struct bt_context)); - if (ctx == NULL) { - perror("allocating context"); - goto error; - } - - ctx->tc = tc; - ctx->refcount = 1; - ctx->last_trace_handle_id = 0; - - return ctx; - -error: - return NULL; -} - -int bt_context_destroy(struct bt_context *ctx) -{ - if (ctx) { - if (ctx->refcount >= 1) - goto ctx_used; - - free(ctx); - } - return 0; - -ctx_used: - return -1; -} - -int bt_context_get(struct bt_context *ctx) -{ - if (!ctx) - return -1; - ctx->refcount++; - return 0; -} - -int bt_context_put(struct bt_context *ctx) -{ - if (!ctx) - return -1; - - ctx->refcount--; - if (ctx->refcount == 0) - return bt_context_destroy(ctx); - return 0; -}