summaryrefslogtreecommitdiff
path: root/navit/atom.c
blob: de11ce8bc7ce79b8be10d5f33ff272dd433040f6 (plain)
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
#include <glib.h>
#include "atom.h"

static GHashTable *atom_hash;

char *
atom_lookup(char *name)
{
	if (!atom_hash)
		return NULL;
	return g_hash_table_lookup(atom_hash,name);
}

char *
atom(char *name)
{
	char *id=atom_lookup(name);
	if (id)
		return id;
	if (!atom_hash)
		return NULL;
	id=g_strdup(name);
	g_hash_table_insert(atom_hash, id, id);
	return id;
}

void
atom_init(void)
{
	atom_hash=g_hash_table_new(g_str_hash, g_str_equal);
}