source: trunk/third/librsvg/rsvg-defs.c @ 18275

Revision 18275, 1.8 KB checked in by ghudson, 21 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r18274, which included commits to RCS files with non-trunk default branches.
Line 
1/*
2   rsvg-defs.c: Manage SVG defs and references.
3 
4   Copyright (C) 2000 Eazel, Inc.
5 
6   This program is free software; you can redistribute it and/or
7   modify it under the terms of the GNU Library General Public License as
8   published by the Free Software Foundation; either version 2 of the
9   License, or (at your option) any later version.
10 
11   This program is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14   Library General Public License for more details.
15 
16   You should have received a copy of the GNU Library General Public
17   License along with this program; if not, write to the
18   Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19   Boston, MA 02111-1307, USA.
20 
21   Author: Raph Levien <raph@artofcode.com>
22*/
23
24#include "config.h"
25#include "rsvg-defs.h"
26
27#include <glib/ghash.h>
28#include <glib/gmem.h>
29#include <glib/gstrfuncs.h>
30
31struct _RsvgDefs {
32  GHashTable *hash;
33};
34
35RsvgDefs *
36rsvg_defs_new (void)
37{
38  RsvgDefs *result = g_new (RsvgDefs, 1);
39
40  result->hash = g_hash_table_new (g_str_hash, g_str_equal);
41
42  return result;
43}
44
45RsvgDefVal *
46rsvg_defs_lookup (const RsvgDefs *defs, const char *name)
47{
48  return (RsvgDefVal *)g_hash_table_lookup (defs->hash, name);
49}
50
51void
52rsvg_defs_set (RsvgDefs *defs, const char *name, RsvgDefVal *val)
53{
54  g_hash_table_insert (defs->hash, g_strdup (name), val);
55}
56
57static void
58rsvg_defs_free_each (gpointer key, gpointer value, gpointer user_data)
59{
60  RsvgDefVal *def_val = (RsvgDefVal *)value;
61  g_free (key);
62  def_val->free (def_val);
63}
64
65void
66rsvg_defs_free (RsvgDefs *defs)
67{
68  g_hash_table_foreach (defs->hash, rsvg_defs_free_each, NULL);
69  g_hash_table_destroy (defs->hash);
70  g_free (defs);
71}
Note: See TracBrowser for help on using the repository browser.