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

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