summaryrefslogtreecommitdiffstats
path: root/dbus/dbus-memory.c
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2006-10-21 17:08:08 +0000
committerHavoc Pennington <hp@redhat.com>2006-10-21 17:08:08 +0000
commitafa4ffbd852686633086569cd34942917c5c49af (patch)
tree5b7919a3255aac947f1a4ef130bafadb508db3a9 /dbus/dbus-memory.c
parent65fcbd62876f435f08bbcb6ff4596545b8c87bbd (diff)
2006-10-21 Havoc Pennington <hp@redhat.com>
* dbus/dbus-message.h: put #ifndef DBUS_DISABLE_DEPRECATED around dbus_message_iter_get_array_len(). * throughout: documentation improvements.
Diffstat (limited to 'dbus/dbus-memory.c')
-rw-r--r--dbus/dbus-memory.c51
1 files changed, 41 insertions, 10 deletions
diff --git a/dbus/dbus-memory.c b/dbus/dbus-memory.c
index fbc02c1e..f2400af7 100644
--- a/dbus/dbus-memory.c
+++ b/dbus/dbus-memory.c
@@ -430,6 +430,9 @@ set_guards (void *real_block,
* on all platforms. Returns #NULL if the allocation fails.
* The memory must be released with dbus_free().
*
+ * dbus_malloc() memory is NOT safe to free with regular free() from
+ * the C library. Free it with dbus_free() only.
+ *
* @param bytes number of bytes to allocate
* @return allocated memory, or #NULL if the allocation fails.
*/
@@ -481,6 +484,9 @@ dbus_malloc (size_t bytes)
* return #NULL if bytes is zero on all platforms. Returns #NULL if the
* allocation fails. The memory must be released with dbus_free().
*
+ * dbus_malloc0() memory is NOT safe to free with regular free() from
+ * the C library. Free it with dbus_free() only.
+ *
* @param bytes number of bytes to allocate
* @return allocated memory, or #NULL if the allocation fails.
*/
@@ -741,16 +747,41 @@ _dbus_register_shutdown_func (DBusShutdownFunction func,
*/
/**
- * The D-Bus library keeps some internal global variables, for example
- * to cache the username of the current process. This function is
- * used to free these global variables. It is really useful only for
- * leak-checking cleanliness and the like. WARNING: this function is
- * NOT thread safe, it must be called while NO other threads are using
- * D-Bus. You cannot continue using D-Bus after calling this function,
- * as it does things like free global mutexes created by
- * dbus_threads_init(). To use a D-Bus function after calling
- * dbus_shutdown(), you have to start over from scratch, e.g. calling
- * dbus_threads_init() again.
+ * Frees all memory allocated internally by libdbus and
+ * reverses the effects of dbus_threads_init(). libdbus keeps internal
+ * global variables, for example caches and thread locks, and it
+ * can be useful to free these internal data structures.
+ *
+ * dbus_shutdown() does NOT free memory that was returned
+ * to the application. It only returns libdbus-internal
+ * data structures.
+ *
+ * You MUST free all memory and release all reference counts
+ * returned to you by libdbus prior to calling dbus_shutdown().
+ *
+ * You can't continue to use any D-Bus objects, such as connections,
+ * that were allocated prior to dbus_shutdown(). You can, however,
+ * start over; call dbus_threads_init() again, create new connections,
+ * and so forth.
+ *
+ * WARNING: dbus_shutdown() is NOT thread safe, it must be called
+ * while NO other threads are using D-Bus. (Remember, you have to free
+ * all D-Bus objects and memory before you call dbus_shutdown(), so no
+ * thread can be using libdbus.)
+ *
+ * The purpose of dbus_shutdown() is to allow applications to get
+ * clean output from memory leak checkers. dbus_shutdown() may also be
+ * useful if you want to dlopen() libdbus instead of linking to it,
+ * and want to be able to unload the library again.
+ *
+ * There is absolutely no requirement to call dbus_shutdown() - in fact,
+ * most applications won't bother and should not feel guilty.
+ *
+ * You have to know that nobody is using libdbus in your application's
+ * process before you can call dbus_shutdown(). One implication of this
+ * is that calling dbus_shutdown() from a library is almost certainly
+ * wrong, since you don't know what the rest of the app is up to.
+ *
*/
void
dbus_shutdown (void)