avahi-common/malloc.h File Reference

Memory allocation. More...

#include <sys/types.h>
#include <stdarg.h>
#include <limits.h>
#include <assert.h>
#include <avahi-common/cdecl.h>
#include <avahi-common/gccmacro.h>

Go to the source code of this file.

Data Structures

struct  AvahiAllocator
 Wraps allocator functions. More...

Defines

#define avahi_new(type, n)   ((type*) avahi_new_internal((n), sizeof(type)))
#define avahi_new0(type, n)   ((type*) avahi_new0_internal((n), sizeof(type)))

Functions

void * avahi_malloc (size_t size) AVAHI_GCC_ALLOC_SIZE(1)
 Allocate some memory, just like the libc malloc().
void * avahi_malloc0 (size_t size) AVAHI_GCC_ALLOC_SIZE(1)
 Similar to avahi_malloc() but set the memory to zero.
void avahi_free (void *p)
 Free some memory.
void * avahi_realloc (void *p, size_t size) AVAHI_GCC_ALLOC_SIZE(2)
 Similar to libc's realloc().
char * avahi_strndup (const char *s, size_t l)
 Just like libc's strndup().
void * avahi_memdup (const void *s, size_t l) AVAHI_GCC_ALLOC_SIZE(2)
 Duplicate the given memory block into a new one allocated with avahi_malloc().
void avahi_set_allocator (const AvahiAllocator *a)
 Change the allocator.
char * avahi_strdup_printf (const char *fmt,...) AVAHI_GCC_PRINTF_ATTR12
 Like sprintf() but store the result in a freshly allocated buffer.


Detailed Description

Memory allocation.

Definition in file malloc.h.


Define Documentation

#define avahi_new ( type,
 )     ((type*) avahi_new_internal((n), sizeof(type)))

#define avahi_new0 ( type,
 )     ((type*) avahi_new0_internal((n), sizeof(type)))


Function Documentation

void avahi_free ( void *  p  ) 

Free some memory.

Examples:
client-browse-services.c, and client-publish-service.c.

void* avahi_malloc ( size_t  size  ) 

Allocate some memory, just like the libc malloc().

void* avahi_malloc0 ( size_t  size  ) 

Similar to avahi_malloc() but set the memory to zero.

void* avahi_memdup ( const void *  s,
size_t  l 
)

Duplicate the given memory block into a new one allocated with avahi_malloc().

void* avahi_realloc ( void *  p,
size_t  size 
)

Similar to libc's realloc().

void avahi_set_allocator ( const AvahiAllocator a  ) 

Change the allocator.

May be NULL to return to default (libc) allocators. The structure is not copied!

Examples:
glib-integration.c.

char* avahi_strdup_printf ( const char *  fmt,
  ... 
)

Like sprintf() but store the result in a freshly allocated buffer.

Free this with avahi_free()

char* avahi_strndup ( const char *  s,
size_t  l 
)

Just like libc's strndup().


Generated on Tue Apr 14 04:06:25 2009 for avahi by  doxygen 1.5.8