aboutsummaryrefslogtreecommitdiff
path: root/gconf/gconf-text.c
diff options
context:
space:
mode:
Diffstat (limited to 'gconf/gconf-text.c')
-rw-r--r--gconf/gconf-text.c73
1 files changed, 0 insertions, 73 deletions
diff --git a/gconf/gconf-text.c b/gconf/gconf-text.c
deleted file mode 100644
index 0545293..0000000
--- a/gconf/gconf-text.c
+++ /dev/null
@@ -1,73 +0,0 @@
1/* gconf - General purpose configuration parser.
2 Copyright (C) 2007, 2008, 2009 Sergey Poznyakoff
3
4 This program is free software; you can redistribute it and/or modify it
5 under the terms of the GNU General Public License as published by the
6 Free Software Foundation; either version 3 of the License, or (at your
7 option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License along
15 with this program. If not, see <http://www.gnu.org/licenses/>. */
16
17#ifdef HAVE_CONFIG_H
18# include <config.h>
19#endif
20#include <gconf.h>
21#include <string.h>
22#include <hash.h>
23#include <xalloc.h>
24
25static Hash_table *text_table;
26
27/* Calculate the hash of a string. */
28static size_t
29text_hasher (void const *data, unsigned n_buckets)
30{
31 return hash_string (data, n_buckets);
32}
33
34/* Compare two strings for equality. */
35static bool
36text_compare (void const *data1, void const *data2)
37{
38 return strcmp (data1, data2) == 0;
39}
40
41static void
42text_free (void *data)
43{
44 free (data);
45}
46
47/* Lookup a text. If it does not exist, create it. */
48char *
49gconf_install_text (const char *str)
50{
51 char *text, *s;
52
53 s = xstrdup (str);
54
55 if (!((text_table
56 || (text_table = hash_initialize (0, 0,
57 text_hasher,
58 text_compare,
59 text_free)))
60 && (text = hash_insert (text_table, s))))
61 xalloc_die ();
62
63 if (s != text)
64 free (s);
65 return text;
66}
67
68void
69gconf_destroy_text ()
70{
71 if (text_table)
72 hash_free (text_table);
73}

Return to:

Send suggestions and report system problems to the System administrator.