Go to the documentation of this file.00001 #ifndef foomallochfoo
00002 #define foomallochfoo
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00027 #include <sys/types.h>
00028 #include <stdarg.h>
00029 #include <limits.h>
00030 #include <assert.h>
00031
00032 #include <avahi-common/cdecl.h>
00033 #include <avahi-common/gccmacro.h>
00034
00035 AVAHI_C_DECL_BEGIN
00036
00038 void *avahi_malloc(size_t size);
00039
00041 void *avahi_malloc0(size_t size);
00042
00044 void avahi_free(void *p);
00045
00047 void *avahi_realloc(void *p, size_t size);
00048
00050 static inline void* avahi_new_internal(unsigned n, size_t k) {
00051 assert(n < INT_MAX/k);
00052 return avahi_malloc(n*k);
00053 }
00054
00056 #define avahi_new(type, n) ((type*) avahi_new_internal((n), sizeof(type)))
00057
00059 static inline void* avahi_new0_internal(unsigned n, size_t k) {
00060 assert(n < INT_MAX/k);
00061 return avahi_malloc0(n*k);
00062 }
00063
00065 #define avahi_new0(type, n) ((type*) avahi_new0_internal((n), sizeof(type)))
00066
00068 char *avahi_strdup(const char *s);
00069
00071 char *avahi_strndup(const char *s, size_t l);
00072
00074 void *avahi_memdup(const void *s, size_t l);
00075
00077 typedef struct AvahiAllocator {
00078 void* (*malloc)(size_t size);
00079 void (*free)(void *p);
00080 void* (*realloc)(void *p, size_t size);
00081 void* (*calloc)(size_t nmemb, size_t size);
00082 } AvahiAllocator;
00083
00086 void avahi_set_allocator(const AvahiAllocator *a);
00087
00089 char *avahi_strdup_printf(const char *fmt, ... ) AVAHI_GCC_PRINTF_ATTR12;
00090
00093 char *avahi_strdup_vprintf(const char *fmt, va_list ap);
00096 AVAHI_C_DECL_END
00097
00098 #endif