blob: a6be456287c55cfc599f646837090f1e53ed8c10 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
#include "config.h"
#include <gnunet/platform.h>
#include <gnunet/gnunet_common.h>
#include "gnunet_dbus_lib.h"
#define LOG(kind, ...) GNUNET_log_from(kind, "dbus-arg", __VA_ARGS__)
struct GNUNET_DBUS_Arg
{
char *name;
const char *signature;
unsigned ref_count;
};
struct GNUNET_DBUS_Arg *
GNUNET_DBUS_arg_create (
const char *name,
const char *signature)
{
struct GNUNET_DBUS_Arg *arg = GNUNET_new (struct GNUNET_DBUS_Arg);
arg->name = GNUNET_strdup (name);
arg->signature = signature;
arg->ref_count = 1;
return arg;
};
void
GNUNET_DBUS_arg_ref (
struct GNUNET_DBUS_Arg *arg)
{
arg->ref_count++;
};
void
GNUNET_DBUS_arg_unref (
struct GNUNET_DBUS_Arg *arg)
{
if (arg->ref_count == 0)
{
LOG (GNUNET_ERROR_TYPE_ERROR, "Tried to unreference arg with ref count 0\n");
GNUNET_abort_ ();
};
if (0 == --(arg->ref_count))
{
GNUNET_free (arg->name);
GNUNET_free (arg);
};
};
const char *
GNUNET_DBUS_arg_get_name (
const struct GNUNET_DBUS_Arg *arg)
{
return arg->name;
};
const char *
GNUNET_DBUS_arg_get_signature (
const struct GNUNET_DBUS_Arg *arg)
{
return arg->signature;
};
|