Main Page   Modules   Data Structures   File List   Data Fields   Related Pages  

Memory Allocation
[D-BUS message system public API]

dbus_malloc(), dbus_free(), etc. More...

Defines

#define dbus_new(type, count)   ((type*)dbus_malloc (sizeof (type) * (count)));
 Safe macro for using dbus_malloc(). More...

#define dbus_new0(type, count)   ((type*)dbus_malloc0 (sizeof (type) * (count)));
 Safe macro for using dbus_malloc0(). More...


Typedefs

typedef void(* DBusFreeFunction )(void *memory)
 The type of a function which frees a block of memory. More...


Functions

void * dbus_malloc (size_t bytes)
 Allocates the given number of bytes, as with standard malloc(). More...

void * dbus_malloc0 (size_t bytes)
 Allocates the given number of bytes, as with standard malloc(), but all bytes are initialized to zero as with calloc(). More...

void * dbus_realloc (void *memory, size_t bytes)
 Resizes a block of memory previously allocated by dbus_malloc() or dbus_malloc0(). More...

void dbus_free (void *memory)
 Frees a block of memory previously allocated by dbus_malloc() or dbus_malloc0(). More...

void dbus_free_string_array (char **str_array)
 Frees a NULL-terminated array of strings. More...

void dbus_shutdown (void)
 The D-BUS library keeps some internal global variables, for example to cache the username of the current process. More...


Detailed Description

dbus_malloc(), dbus_free(), etc.

Functions and macros related to allocating and releasing blocks of memory.


Define Documentation

#define dbus_new type,
count       ((type*)dbus_malloc (sizeof (type) * (count)));
 

Safe macro for using dbus_malloc().

Accepts the type to allocate and the number of type instances to allocate as arguments, and returns a memory block cast to the desired type, instead of as a void*.

Parameters:
type  type name to allocate
count  number of instances in the allocated array
Returns:
the new memory block or NULL on failure

Definition at line 41 of file dbus-memory.h.

#define dbus_new0 type,
count       ((type*)dbus_malloc0 (sizeof (type) * (count)));
 

Safe macro for using dbus_malloc0().

Accepts the type to allocate and the number of type instances to allocate as arguments, and returns a memory block cast to the desired type, instead of as a void*. The allocated array is initialized to all-bits-zero.

Parameters:
type  type name to allocate
count  number of instances in the allocated array
Returns:
the new memory block or NULL on failure

Definition at line 42 of file dbus-memory.h.


Typedef Documentation

DBusFreeFunction
 

The type of a function which frees a block of memory.

Parameters:
memory  the memory to free

Definition at line 46 of file dbus-memory.h.


Function Documentation

void dbus_free void *    memory
 

Frees a block of memory previously allocated by dbus_malloc() or dbus_malloc0().

If passed NULL, does nothing.

Parameters:
memory  block to be freed

Definition at line 605 of file dbus-memory.c.

void dbus_free_string_array char **    str_array
 

Frees a NULL-terminated array of strings.

If passed NULL, does nothing.

Parameters:
str_array  the array to be freed

Definition at line 643 of file dbus-memory.c.

void* dbus_malloc size_t    bytes
 

Allocates the given number of bytes, as with standard malloc().

Guaranteed to return NULL if bytes is zero on all platforms. Returns NULL if the allocation fails. The memory must be released with dbus_free().

Parameters:
bytes  number of bytes to allocate
Returns:
allocated memory, or NULL if the allocation fails.

Definition at line 430 of file dbus-memory.c.

void* dbus_malloc0 size_t    bytes
 

Allocates the given number of bytes, as with standard malloc(), but all bytes are initialized to zero as with calloc().

Guaranteed to return NULL if bytes is zero on all platforms. Returns NULL if the allocation fails. The memory must be released with dbus_free().

Parameters:
bytes  number of bytes to allocate
Returns:
allocated memory, or NULL if the allocation fails.

Definition at line 481 of file dbus-memory.c.

void* dbus_realloc void *    memory,
size_t    bytes
 

Resizes a block of memory previously allocated by dbus_malloc() or dbus_malloc0().

Guaranteed to free the memory and return NULL if bytes is zero on all platforms. Returns NULL if the resize fails. If the resize fails, the memory is not freed.

Parameters:
memory  block to be resized
bytes  new size of the memory block
Returns:
allocated memory, or NULL if the resize fails.

Definition at line 532 of file dbus-memory.c.

void dbus_shutdown void   
 

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.

Definition at line 749 of file dbus-memory.c.

References ShutdownClosure::data, ShutdownClosure::func, and ShutdownClosure::next.


Generated on Wed Jun 9 05:01:28 2004 for D-BUS by doxygen1.2.15