~ubuntu-branches/ubuntu/maverick/telepathy-glib/maverick

« back to all changes in this revision

Viewing changes to telepathy-glib/util.c

  • Committer: Bazaar Package Importer
  • Author(s): Simon McVittie
  • Date: 2010-06-14 17:42:08 UTC
  • mfrom: (1.6.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20100614174208-7b6teypo8jnx5uux
Tags: 0.11.7-1
* New upstream version
  - requires gobject-introspection 0.6.13
  - new ABI, API

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * util.c - Source for telepathy-glib utility functions
3
 
 * Copyright (C) 2006-2007 Collabora Ltd. <http://www.collabora.co.uk/>
4
 
 * Copyright (C) 2006-2007 Nokia Corporation
5
 
 *   @author Robert McQueen <robert.mcqueen@collabora.co.uk>
 
3
 * Copyright © 2006-2010 Collabora Ltd. <http://www.collabora.co.uk/>
 
4
 * Copyright © 2006-2008 Nokia Corporation
6
5
 *
7
6
 * This library is free software; you can redistribute it and/or
8
7
 * modify it under the terms of the GNU Lesser General Public
52
51
 * (This is gnulib's verify macro, written by Paul Eggert, Bruno Haible and
53
52
 * Jim Meyering.)
54
53
 *
 
54
 * This macro will be deprecated in a future telepathy-glib release. Please
 
55
 * use GLib 2.20's G_STATIC_ASSERT() macro in new code.
 
56
 *
55
57
 * Since: 0.7.34
56
58
 */
57
59
 
70
72
 * (This is gnulib's verify_true macro, written by Paul Eggert, Bruno Haible
71
73
 * and Jim Meyering.)
72
74
 *
 
75
 * This macro will be deprecated in a future telepathy-glib release. Please
 
76
 * use GLib 2.20's G_STATIC_ASSERT() macro in new code.
 
77
 *
73
78
 * Returns: 1
74
79
 *
75
80
 * Since: 0.7.34
86
91
 * This macro can be used anywhere that a statement would be allowed; it
87
92
 * is equivalent to ((void) tp_verify_true (R)).
88
93
 *
 
94
 * This macro will be deprecated in a future telepathy-glib release. Please
 
95
 * use GLib 2.20's G_STATIC_ASSERT() macro in new code.
 
96
 *
89
97
 * Since: 0.7.34
90
98
 */
91
99
 
1251
1259
 
1252
1260
  g_slice_free (TpWeakRef, self);
1253
1261
}
 
1262
 
 
1263
/**
 
1264
 * tp_clear_object: (skip)
 
1265
 * @op: (allow-none): a pointer to a variable, struct member etc. holding a
 
1266
 *  #GObject
 
1267
 *
 
1268
 * Set a variable holding a #GObject to %NULL. If it was not already %NULL,
 
1269
 * unref the object it previously pointed to.
 
1270
 *
 
1271
 * This is exactly equivalent to calling tp_clear_pointer() on @op,
 
1272
 * with @destroy = g_object_unref(). See tp_clear_pointer() for example usage.
 
1273
 *
 
1274
 * Since: 0.11.7
 
1275
 */
 
1276
 
 
1277
/**
 
1278
 * tp_clear_pointer: (skip)
 
1279
 * @pp: (allow-none): a pointer to a variable, struct member etc. holding a
 
1280
 *  pointer
 
1281
 * @destroy: a function to which a gpointer can be passed, to destroy *@pp
 
1282
 *  (if calling this macro from C++, explicitly casting the function to
 
1283
 *  #GDestroyNotify may be necessary)
 
1284
 *
 
1285
 * Set a variable holding a pointer to %NULL. If it was not already %NULL,
 
1286
 * unref or destroy the object it previously pointed to with @destroy.
 
1287
 *
 
1288
 * More precisely, if both @pp and *@pp are non-%NULL, set *@pp to %NULL, then
 
1289
 * call @destroy on the object that *@pp previously pointed to.
 
1290
 *
 
1291
 * This is analogous to g_clear_error() for non-error objects, but also
 
1292
 * ensures that @pp is already %NULL before the destructor is run.
 
1293
 *
 
1294
 * Typical usage is something like this:
 
1295
 *
 
1296
 * |[
 
1297
 * typedef struct {
 
1298
 *   TpConnection *conn;
 
1299
 *   GError *error;
 
1300
 *   GHashTable *table;
 
1301
 *   MyStruct *misc;
 
1302
 * } Foo;
 
1303
 * Foo *foo;
 
1304
 *
 
1305
 * ...
 
1306
 *
 
1307
 * tp_clear_object (&amp;foo->conn);
 
1308
 * g_clear_error (&amp;foo->error);
 
1309
 * tp_clear_boxed (G_TYPE_HASH_TABLE, &amp;foo->table);
 
1310
 * tp_clear_pointer (&amp;foo->misc, my_struct_destroy);
 
1311
 * ]|
 
1312
 *
 
1313
 * Since: 0.11.7
 
1314
 */
 
1315
 
 
1316
/**
 
1317
 * tp_clear_boxed: (skip)
 
1318
 * @gtype: (type GObject.Type): the #GType of *@pp, e.g. %G_TYPE_HASH_TABLE
 
1319
 * @pp: (allow-none): a pointer to a variable, struct member etc. holding a
 
1320
 *  boxed object
 
1321
 *
 
1322
 * Set a variable holding a boxed object to %NULL. If it was not already %NULL,
 
1323
 * destroy the boxed object it previously pointed to, as appropriate for
 
1324
 * @gtype.
 
1325
 *
 
1326
 * More precisely, if both @pp and *@pp are non-%NULL, set *@pp to %NULL, then
 
1327
 * call g_boxed_free() on the object that *@pp previously pointed to.
 
1328
 *
 
1329
 * This is similar to tp_clear_pointer(); see that function's documentation
 
1330
 * for typical usage.
 
1331
 *
 
1332
 * Since: 0.11.7
 
1333
 */