]> git.proxmox.com Git - ceph.git/blame - ceph/src/jaegertracing/thrift/lib/c_glib/src/thrift/c_glib/thrift.c
buildsys: switch source download to quincy
[ceph.git] / ceph / src / jaegertracing / thrift / lib / c_glib / src / thrift / c_glib / thrift.c
CommitLineData
f67539c2
TL
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20#include <thrift/c_glib/thrift.h>
21
22/**
23 * GHashTable callback to add keys to a GList.
24 */
25void
26thrift_hash_table_get_keys (gpointer key, gpointer value, gpointer user_data)
27{
28 GList **list = (GList **) user_data;
29
30 THRIFT_UNUSED_VAR (value);
31
32 *list = g_list_append (*list, key);
33}
34void thrift_safe_hash_table_destroy(GHashTable* hash_table)
35{
36 if (hash_table)
37 {
38 g_hash_table_destroy(hash_table);
39 }
40}
41
42guint thrift_boolean_hash(gconstpointer v)
43{
44 const gboolean* p = v;
45 return p && *p ? 1 : 0;
46}
47gboolean thrift_boolean_equal(gconstpointer a, gconstpointer b)
48{
49 if (a == b) {
50 return TRUE;
51 }
52 if (!a || !b) {
53 return FALSE;
54 }
55 const gboolean* pa = a;
56 const gboolean* pb = b;
57 return *pa == *pb;
58}
59
60guint thrift_int8_hash(gconstpointer v)
61{
62 const gint8* p = v;
63 return p ? *p : 0;
64}
65gboolean thrift_int8_equal(gconstpointer a, gconstpointer b)
66{
67 if (a == b) {
68 return TRUE;
69 }
70 if (!a || !b) {
71 return FALSE;
72 }
73 const gint8* pa = a;
74 const gint8* pb = b;
75 return *pa == *pb;
76}
77
78guint thrift_int16_hash(gconstpointer v)
79{
80 const gint16* p = v;
81 return p ? *p : 0;
82}
83gboolean thrift_int16_equal(gconstpointer a, gconstpointer b)
84{
85 if (a == b) {
86 return TRUE;
87 }
88 if (!a || !b) {
89 return FALSE;
90 }
91 const gint16* pa = a;
92 const gint16* pb = b;
93 return *pa == *pb;
94}
95
96void
97thrift_string_free (gpointer str)
98{
99 GByteArray* ptr = str;
100 g_byte_array_unref(ptr);
101}