~ubuntu-branches/ubuntu/maverick/libchamplain/maverick

« back to all changes in this revision

Viewing changes to champlain/champlain-map-source-desc.c

  • Committer: Bazaar Package Importer
  • Author(s): Sjoerd Simons, Laurent Bigonville, Sjoerd Simons
  • Date: 2009-09-15 00:01:41 UTC
  • mfrom: (1.1.3 upstream) (2.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20090915000141-i8fg5n1t02zxo79m
Tags: 0.4.0-1
[ Laurent Bigonville ]
* debian/control: Add libchamplain-0.3-dev dependency to
  libchamplain-gtk-0.3-dev

[ Sjoerd Simons ]
* New upstream release (0.4.0)

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
 * @desc: a #ChamplainMapSourceDesc
47
47
 *
48
48
 * Makes a copy of the map source desc structure.  The result must be
49
 
 * freed using champlain_map_source_desc_free().
 
49
 * freed using #champlain_map_source_desc_free.  All string fields will
 
50
 * be duplicated with #g_strdup.
50
51
 *
51
52
 * Return value: an allocated copy of @desc.
52
53
 *
55
56
ChamplainMapSourceDesc *
56
57
champlain_map_source_desc_copy (const ChamplainMapSourceDesc *desc)
57
58
{
58
 
  if (G_LIKELY (desc != NULL))
59
 
    return g_slice_dup (ChamplainMapSourceDesc, desc);
60
 
 
61
 
  return NULL;
 
59
  ChamplainMapSourceDesc *dest = NULL;
 
60
  if (G_UNLIKELY (desc == NULL))
 
61
    return NULL;
 
62
 
 
63
  dest = g_slice_dup (ChamplainMapSourceDesc, desc);
 
64
  if (G_LIKELY (desc->id != NULL))
 
65
    dest->id = g_strdup (desc->id);
 
66
 
 
67
  if (G_LIKELY (desc->name != NULL))
 
68
    dest->name = g_strdup (desc->name);
 
69
 
 
70
  if (G_LIKELY (desc->license != NULL))
 
71
    dest->license = g_strdup (desc->license);
 
72
 
 
73
  if (G_LIKELY (desc->license_uri != NULL))
 
74
    dest->license_uri = g_strdup (desc->license_uri);
 
75
 
 
76
  if (G_LIKELY (desc->uri_format != NULL))
 
77
    dest->uri_format = g_strdup (desc->uri_format);
 
78
 
 
79
  // Can't make a copy of obscure pointer data
 
80
  dest->data = desc->data;
 
81
 
 
82
  return dest;
62
83
}
63
84
 
64
85
/**
66
87
 * @desc: a #ChamplainMapSourceDesc
67
88
 *
68
89
 * Frees a desc structure created with #champlain_map_source_desc_new or
69
 
 * #champlain_map_source_desc_copy
 
90
 * #champlain_map_source_desc_copy. All strings will be freed with #g_free.
 
91
 * The data pointer will not be freed.
70
92
 *
71
93
 * Since: 0.4
72
94
 */
80
102
  if (G_LIKELY (desc->id != NULL))
81
103
    g_free (desc->id);
82
104
 
 
105
  if (G_LIKELY (desc->name != NULL))
 
106
    g_free (desc->name);
 
107
 
 
108
  if (G_LIKELY (desc->license != NULL))
 
109
    g_free (desc->license);
 
110
 
 
111
  if (G_LIKELY (desc->license_uri != NULL))
 
112
    g_free (desc->license_uri);
 
113
 
 
114
  if (G_LIKELY (desc->uri_format != NULL))
 
115
    g_free (desc->uri_format);
 
116
 
83
117
  g_slice_free (ChamplainMapSourceDesc, desc);
84
118
}
85
119
 
86
120
/**
87
121
 * champlain_map_source_desc_new:
88
 
 * @lat: the latitude
89
 
 * @lon: the longitude
90
122
 *
91
 
 * Return value: a newly allocated #ChamplainMapSourceDesc to be freed with #champlain_map_source_desc_free
 
123
 * Returns: a newly allocated #ChamplainMapSourceDesc to be freed with #champlain_map_source_desc_free
92
124
 *
93
125
 * Since: 0.4
94
126
 */